# YAM(ath)T: How to calculate 11111 mod 37?

#### ndee

##### Lifer
Hello there,
I don't want you guys to solve my problems, I'm wondering if someone could explain me how to calculate that stuff, without using a calculator. I'm sure there is somewhere a "trick" but I can't seem to find it.

Any help is appreciated.

Thanks

#### sao123

##### Lifer
Originally posted by: ndee
Hello there,
I don't want you guys to solve my problems, I'm wondering if someone could explain me how to calculate that stuff, without using a calculator. I'm sure there is somewhere a "trick" but I can't seem to find it.

Any help is appreciated.

Thanks

Um.... long division on paper????
mod = division... except the answer is the remainder instead of the quotient....

90%4=??

-------
4|90

...2
-------
4|90
...8 |
---- |
....10

...22
-------
4|90
...8 |
---- |
....10
....08
-------
.......2

9%4 = 2

type in:
11111 % 37

#### purbeast0

##### No Lifer
lol ... mod is just doing long whoe number division as the first poster said, but the answer is the remainder.

i hope you aren't a comp sci major.

#### ndee

##### Lifer
Yes, I know what "mod" does. I'm just asking if there is an "elegant" way to resolve 11111 mod 37, maybe with "Remainder"-Classes? (That's how it's called in German)

#### SaturnX

##### Diamond Member
Wow, I did this back in 1st year... now if I remember correctly, (i may be completely off on this), but it involved breaking down the number, prime factors maybe? I remember breaking the numbers down... then again it was a couple years ago, so I might be completely off base.. the course doesn't even have any practical application in my upper year courses so I haven't been bothered to remember how to do it.

--Mark

explain me

#### ndee

##### Lifer
Originally posted by: SaturnX
Wow, I did this back in 1st year... now if I remember correctly, (i may be completely off on this), but it involved breaking down the number, prime factors maybe? I remember breaking the numbers down... then again it was a couple years ago, so I might be completely off base.. the course doesn't even have any practical application in my upper year courses so I haven't been bothered to remember how to do it.

--Mark

gonna test it thanks for the hint!

#### Kyteland

##### Diamond Member
Originally posted by: SaturnX
Wow, I did this back in 1st year... now if I remember correctly, (i may be completely off on this), but it involved breaking down the number, prime factors maybe? I remember breaking the numbers down... then again it was a couple years ago, so I might be completely off base.. the course doesn't even have any practical application in my upper year courses so I haven't been bothered to remember how to do it.

--Mark

#### mugs

##### Lifer
The way I do it if I have to do it with a calculator would be:

X mod Y
1. Z = (X / Y)
2. Round Z down to nearest whole number
3. X - (Z * Y)

So:
1. 11111 / 37 = 300.297297
2. Z = 300
3 11 111 - (37 * 300) = 11

Or in code:
X - ((int)(X / Y) * Y)

Casting it to an int is not necessary if X and Y are ints since it'll automatically truncate the result.

If you're doing it by hand, use long division.

#### DaiShan

##### Diamond Member
Originally posted by: mugs
The way I do it if I have to do it without a calculator would be:

X mod Y
1. Z = (X / Y)
2. Round Z down to nearest whole number
3. X - (Z * Y)

So:
1. 11111 / 37 = 300.297297
2. Z = 300
3 11 111 - (37 * 300) = 11

Yeah, why is this so difficult a concept, don't they teach long division in elementary school any more? Modulus just tells you to do long division and instead of having a whole number followed by a decimal point, you just give the remainder. It's actually easier than giving a decimal...