• 0

Calculating 13 (mod 2436) (Modulo)


Question

I feel so very stupid right now. I understand modulus...this is not a hard task. What I am having difficulty with is how to calculate something similar to above (a = b (mod m) <-- note parenthesis, this makes it different from modulus). I am writing the answer to a Java project for my Discrete Math class. I have searched google, answers.com and neowin for how to calculate this, but to no avail. I think I need to take a break and see if I can get some neowin assistance.

What I do know is that a -13 should be a multiple of 2436...however when I do this I don't get the same answer my professor, and sites on the internet show.

Also a mod m == b mod m. But that doesn't seem to work for me either.

Is anybody on Neowin able to help here? Thank you!

Link to comment
https://www.neowin.net/forum/topic/553858-calculating-13-mod-2436-modulo/
Share on other sites

11 answers to this question

Recommended Posts

  • 0
  benjaminzsj said:
a is the remainder, is this your confusion?

You are thinking Mosulus, I am looking for Modulo. I think I figured it out somewhat though. In the example above it would be 937 is congruent to 13 (mod 2436)...this is because 937*13 = 12181 and is one off of a multiple of 2436. I don't quite understand why. My current algorithm works, but is dog slow.

I am using relatively small numbers too (in the billions). Anybody know a good method for calculating Modulo in Java?

  • 0
  mpat1024 said:
13 mod 2436 is just 13.

Basically divide 13 by 2436 and take the remainder.

2436 mod 13 is 5, as 2436/13 = 187 r.5

Again, that is not the issue. Noticed parenthesis--> 13 (mod 2436).

The answer is not 13 in this case.

I have figured this part out. My next question is: I am having trouble writing a Java Method for calculating MODULO. Could anybody provide such info on a method?

  • 0

You're looking for congruence, right?

b = c (mod m)

so

(b-c)/m would be congruent if the result is an integer, as I understand it.

I ran a test from 1 to 25000 and came up with:

13

2449

4885

7321

9757

12193

14629

17065

19501

21937

24373

http://mathworld.wolfram.com/Congruence.html

  • 0
  mastermate said:
What answer do they show?

They show 937...which I partially understand now. I am beginning to believe that "congruent" means off by 1. So 937 * 13 = 12181 and 12180 is a multiple of 2436 (2436*5). Thus 937 is congruent to 13 (mod 2436). I think I may have figured out that I can use the Chinese Remainder Thereom to find the modulo. Can anybody confirm this? And could anybody provide any insight as to how?

I guess I should explain the project a little. We are writing an RSA Encryption/Decryption algorithm. Part of calculating the decryption key uses your existing private keys and the modulo (Not Modulus) to find the inverse of the encryption key (Exponent as it is called). So since this is dealing with encryption/decryption keys they can become very large (to deter cracking). My current algorithm is very slow, and this is for small keys. So could anybody help?

  azcodemonkey said:
You're looking for congruence, right?

b = c (mod m)

so

(b-c)/m would be congruent if the result is an integer, as I understand it.

I ran a test from 1 to 25000 and came up with:

13

2449

4885

7321

9757

12193

14629

17065

19501

21937

24373

http://mathworld.wolfram.com/Congruence.html

You seem to know what you are taking about. Could I use the Chinese Remainder Thereom to speed up my decryption? See my post above.

Right now finding the inverse key (de) of e takes a few seconds. This is with small numbers too.

  • 0
  Quote
I am beginning to believe that "congruent" means off by 1.

This is wrong, you might want to take a close look at the RSA algorithm. "off by 1" is required by RSA, not the definition of congruent. Maybe you were saying ed=1 mod f(n),?where f(n)=(p-1)(q-1).

I don't know about Java, but you can't use int or whatever?is already a simple type in C, they are not big enough. You have to create a new self-defined type to implement RSA.

  • 0
  Staind said:
This is wrong, you might want to take a close look at the RSA algorithm. "off by 1" is required by RSA, not the definition of congruent. Maybe you were saying ed=1 mod f(n), where f(n)=(p-1)(q-1).

I don't know about Java, but you can't use int or whatever is already a simple type in C, they are not big enough. You have to create a new self-defined type to implement RSA.

I have some algorithms that I can use for really big numbers. They don't use native data types, but actually store numbers as binary and perform the simple binary algebra. This isn't my problem. I am trying to figure out how this whole modulo thing works. I am going to try the Chinese Remainder Thereom with P,Q, and N and see if it comes up correctly. I also have class tomorrow night, so I am going to ask my professor what I should be doing. Thank you for responding!

  • 0

There seems to be a lot of confusion over terminology.

"a modulo n", written "a (mod n)" or "a % n", typically denotes finding the remainder of n divided by a. The term modulus is typically used in RSA and refers to n=pq. It can also refer to the "n" in "a (mod n)". Also note that one style (the one I use) is to bracket "mod n", but it is acceptable to omit the brackets. The two forms mean the same thing (i.e parentheses don't matter).

If a = b (mod n) we say that "a is congruent to b modulo (or mod) n". This means that a - b = kn for some k. So for example 2 = 9 = 16 = 23 (mod 7).

The OP is trying to compute inverses (mod n). That is, given "a" the OP wants to find "b" such that ab = 1 (mod n) with b between 0 and n-1 inclusive. We say that b = a^-1 (mod n). In the example given, the OP notes that 13^-1 = 937 (mod 2436). To see this is true, we note that 13*937 = 1 (mod 2436), since 13*937 - 1 = 5*2436 (so k = 5).

You can do this using the Extended Euclidean Algorithm, which you can read about on wikipedia.

  • 0

So this seems to be one of those things in life where we are our worst enemy. The concept is simple, but I failed to allow myself to comprehend this subject. I now get it! I would like to thank those that were able to provide me with the information I needed to get this problem solved.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I have two Tab S9 FEs and two Tab A9+ tablets. While the Tab A9+ is not as powerful as the Tab S9 FE, I like the much cheaper Tab A9+ better. It has a slightly more Landscapish display for those who use the Landscape mode. I haven't noticed much difference in the speakers. The S9 FE does better on battery drainage at around 7% an hour vs 9% an hour for the Tab A9+. I don't use Fast Charging because it is not good for the battery and I haven't really compared the charge time between the two. One thing for sure is the Tab A9+ does a lot better at handling memory under Android 15 UI 7 than it did under Android 14, UI 6.1. The Tab A10+ has yet to be released and as I understand it, it has major chipset and charging upgrades. It expected to be released late this summer or early fall, but with all Samsung hardware releases, I imagine this one will be same where the U.S. is not among the early markets to see a new device.
    • As such, about 30,000 government sector computers would be switching by 2027 or so. I have been there and done it though probably not with as many as 30,000 computers. i worked on a Bank of America conversion project and it was a mess, a complete mess. Computer system conversions are never as easy as they sound in the media or even the Corporate Boardroom or Government high-up offfices. One may ask, what MIcrosoft hardware and sofware the government of Denmark is using in addition to desktop computers and Office?. One thing for sure. We know that they aren't using Windows 10 Mobile.
    • WTF? I can't believe you are surprised it's not an option or it should be. 
    • Yes, if the PCs aren’t upgraded, they’ll lack features like TPM and remain vulnerable to driver and hardware-level exploits. That includes CPU flaws, RAM vulnerabilities, boot and BIOS attacks, and so on. Realistically, there should have been a steady programme of hardware refreshes rather than allowing systems to age well past their practical and secure lifespan. Are we seriously entertaining the idea of running Linux on machines that are over a decade old as a long-term solution instead of upgrading? Would you entrust your financial data or medical records to a box from the early 2000s, with Windows XP removed and Linux installed in its place? Performance degradation is not just an inconvenience. It affects productivity. Slow machines cost time, and time costs money. Security flaws do too. Hardware and software upgrades should be part of a rolling, responsible IT strategy. They should not be treated as an afterthought. This kind of complacency is precisely the issue we’ve seen before. Just look at how that played out in the UK. We readily replace construction tools such as drills, saws, and other equipment on a regular basis, and many of those cost more than a standard desktop PC. Yet when it comes to computers, we’re still stuck in the mindset of "if it isn’t broken, don’t fix it." Just because something powers on doesn’t mean it is fit for purpose. The horse and cart did the job at one point too, but that didn’t mean it was wise to stick with it when something better came along.
    • Freshly released Samsung Galaxy Tab S10 FE is already discounted by Fiza Ali The Samsung Galaxy Tab S10 FE is already available at a discount, just two months after its debut, so you may want to check it out. The device is powered by the Samsung Exynos 1580 processor and equipped with 12GB of RAM and 256GB of internal storage, which can be expanded by up to 1TB via microSD. It features a 10.9‑inch LCD display with a resolution of 2,304 x 1,440 pixels and a 90 Hz refresh rate. Photography and video calls are handled by a 13MP rear camera and a 12MP ultra‑wide front‑facing camera. The device further includes dual AKG‑tuned speakers for immersive audio. The Galaxy Tab S10 FE offers Sub‑6 5G, dual‑band Wi‑Fi 6 with Wi‑Fi Direct support, and Bluetooth 5.3 for low‑latency wireless connections. Moreover, it incorporates S Pen functionality with handwriting assist, a Circle to Search feature for instant Google look‑ups, and Math Solver for converting handwritten equations into editable text and step‑by‑step solutions. The tablet comes pre‑loaded with a suite of creative and productivity apps, including LumaFusion, GoodNotes, Clip Studio Paint, Noteshelf, Sketchbook and PicsArt. The Galaxy Tab S10 FE is water‑resistant, safeguarding against spills, splashes, and brief immersion, and includes a dedicated AI hot‑key on its keyboard for quick access to on‑device artificial intelligence tools. Finally, the tablet houses an 8,000 mAh lithium‑ion battery (29.95Wh) that is said to deliver up to 20 hours of continuous use and supports Super Fast Charging. Samsung Galaxy Tab S10 FE: $519.99 (Amazon US) 9% off This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Explorer
      Case_f went up a rank
      Explorer
    • Conversation Starter
      Jamie Smith earned a badge
      Conversation Starter
    • First Post
      NeoToad777 earned a badge
      First Post
    • Week One Done
      JoeV earned a badge
      Week One Done
    • One Month Later
      VAT Services in UAE earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      549
    2. 2
      ATLien_0
      240
    3. 3
      +Edouard
      160
    4. 4
      +FloatingFatMan
      147
    5. 5
      Michael Scrip
      112
  • Tell a friend

    Love Neowin? Tell a friend!