HACKER RANK Project Euler 63 - Powerful Digit Counts - Solution.'Py'
Project Euler Challenges-63 - Powerful Digit Counts Solution
Problem Statement
This problem is a programming version of Problem 63 from projecteuler.net
The 5−digit number, 16807=75 , is also a fifth power. Similarly, the 9-digit number, 134217728=89 , is a ninth power.
Given N , print the N−digit positive integers which are also an Nth power?
Input Format
Input contains an integer N
Output Format
Print the answer corresponding to the test case.
Constraints
1≤N≤19
Sample Input
2
Sample Output
16
25
36
49
64
81
Problem Statement
This problem is a programming version of Problem 63 from projecteuler.net
The 5−digit number, 16807=75 , is also a fifth power. Similarly, the 9-digit number, 134217728=89 , is a ninth power.
Given N , print the N−digit positive integers which are also an Nth power?
Input Format
Input contains an integerN
Input contains an integer
Output Format
Print the answer corresponding to the test case.
Print the answer corresponding to the test case.
Constraints
1≤N≤19
Sample Input
2
Sample Output
16
25
36
49
64
81
Solution:
a = input()
i = 1
j = 1
while (j < 10**a):
j= i**a
if (j>10**(a-1) and j<10**a):
print j
i+=1
a = input()
i = 1
j = 1
while (j < 10**a):
j= i**a
if (j>10**(a-1) and j<10**a):
print j
i+=1
Comments
Post a Comment