From charlesreid1

Line 6: Line 6:


==Solution Technique==
==Solution Technique==
This one is almost embarrassingly easy...
To check if a number <math>a^b</math> is <math>b</math> digits, we can take <math>\log_{10}(b)</math> and if the value, rounded up, is <math>b</math>, our criteria is met.
For this particular problem, we can stop at <math>n=25</math>, since <code>ceil(log10(9**25)) = 25</code>


==Code==
==Code==

Revision as of 10:29, 8 January 2018

Problem Statement

How many n-digit positive integers exist which are also an nth power?

Link: https://projecteuler.net/problem=63

Solution Technique

This one is almost embarrassingly easy...

To check if a number $ a^b $ is $ b $ digits, we can take $ \log_{10}(b) $ and if the value, rounded up, is $ b $, our criteria is met.

For this particular problem, we can stop at $ n=25 $, since ceil(log10(9**25)) = 25

Code

Link: https://charlesreid1.com:3000/cs/euler/src/master/scratch/Round2_050-070/063

Flags