Problem 3079. Big numbers, repeated least significant digits
Given an integer x which contains d digits, find the value of (minimum) n (n > 1) such that the last d digits of x^n is equal to x. If the last d digits will never equal x, return inf.
Example 1:
- x = 2; (therefore d = 1)
- 2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32
- n = 5;
Example 2:
- x = 10; (therefore d = 2)
- 10^2 = 100, 10^3 = 1000, etc
- n = inf;
Solution Stats
Problem Comments
-
3 Comments
rifat
on 14 Mar 2015
is it correct for 35197? Im getting 5001 instead of inf.
Tim
on 15 Mar 2015
I also get 5001.
Rafael S.T. Vieira
on 3 Sep 2020
10016 and 10081 have another valid answer: 1251 (besides 626). The problem should accept them or request the minimum exponent.
Solution Comments
Show commentsGroup

Project Euler II
- 12 Problems
- 51 Finishers
- Sums of cubes and squares of sums
- Sum of big primes without primes
- Project Euler: Problem 11, Largest product in a grid
- Highly divisible triangular number (inspired by Project Euler 12)
- Divisors for big integer
- Large Sum (inspired by Project Euler 13)
- Longest Collatz Sequence
- Project Euler: Problem 16, Sums of Digits of Powers of Two
- Project Euler: Problem 18, Maximum path sum I
- Recurring Cycle Length (Inspired by Project Euler Problem 26)
- Numbers spiral diagonals (Part 1)
- Numbers spiral diagonals (Part 2)
Problem Recent Solvers73
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!