### Random Post

### Recent Posts

### Recent Comments

geoffrounce on Enigma 440: Three X | |

Jim Randell on Enigma 1588: As easy as 1… | |

Jim Randell on Enigma 440: Three X | |

geoffrounce on Enigma 1106: Not a square… | |

Jim Randell on Tantalizer 458: Knifemen |

### Archives

### Categories

- article (11)
- enigma (1,156)
- misc (2)
- project euler (2)
- puzzle (39)
- site news (44)
- tantalizer (42)
- teaser (3)

### Site Stats

- 177,401 hits

Advertisements

Python’s built-in

pow()can compute problems like this directly. This Python program (statement) runs in 23ms.Solution:The last five digits of 7777777^{7777777}are 47697.The problem is similar to

Enigma 1494. Here’s a program that uses Euler’s Theorem [ http://en.wikipedia.org/wiki/Euler%27s_theorem ] to reduce the exponent and then use repeated squaring to calculate the result in 15 iterations (rather than 23 iterations for calculatingmpow(A, B, M)directly).A variation on the same theme also appeared in

IBM Ponder This, October 2014In Mathematica, Print[PowerMod[7777777, 7777777, 100000]] also gives 47697 as the answer.