3

This is a homework question.

I need to calculate 45^60 mod 61. I want to know of any fast method to get the result either programmatically or manually whichever is faster.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Bruteforce
  • 31
  • 1

5 Answers5

21

The result would be 1 because of Fermat's little theorem

enter image description here

if p is prime.

61 is a prime number so ap-1 when divided by p would give 1 as the remainder.

However if p is non-prime the usual trick is repeated-squaring.

Prasoon Saurav
  • 91,295
  • 49
  • 239
  • 345
6
45^60 =
2025^30 = (33*61 + 12)^30 = 12^30 =
144^15 = (2*61 + 22)^15 = 22^15 =
10648^5 = ( 174*61 + 34)^5 = 34^5 =
45435424 = 744843 * 61 + 1 = 1

Here equality means = (mod 61)

Markus Jarderot
  • 86,735
  • 21
  • 136
  • 138
MKo
  • 4,768
  • 8
  • 32
  • 35
4

I would say your best bet would be to use Fermat's Little Theorem.

Fermat's Little Theorem

where p = 61 and p-1 = 60.

Hope that helps

Chris McKnight
  • 8,540
  • 4
  • 29
  • 31
1
45^2         = 2025 = 12
45^4  = 12^2 = 144  = 22
45^8  = 22^2 = 484  = 57
45^16 = 57^2 = 3249 = 16
45^32 = 16^2 = 256  = 12

45^60 = 45^(4+8+16+32) = 22 * 57 * 16 * 12 = 1
aaz
  • 5,136
  • 22
  • 18
0

Wolfram Alpha

Always have Wolfram Alpha at hand :D

enter image description here

Dr. belisarius
  • 60,527
  • 15
  • 115
  • 190