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
Solution Comments
Show comments
Loading...
Problem Recent Solvers86
Suggested Problems
-
How long is the longest prime diagonal?
409 Solvers
-
Determine if input is a Narcissistic number
217 Solvers
-
Simple equation: Annual salary
4256 Solvers
-
Write a function man that takes a row vector v and returns a matrix H as follows..
646 Solvers
-
Spot the First Occurrence of 5
433 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
is it correct for 35197? Im getting 5001 instead of inf.
I also get 5001.
10016 and 10081 have another valid answer: 1251 (besides 626). The problem should accept them or request the minimum exponent.