We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #63: Powerful digit counts
Project Euler #63: Powerful digit counts
Sort by
recency
|
45 Discussions
|
Please Login in order to post a comment
Simple solution in python:
Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n>0 && n<20){ for(int i=1;i<=19;i++){ int x=(int)Math.pow(i,n); // int y=n; //converted num into string to calculate the no of degits inside of the string
String str=String.valueOf(x); if(str.length()==n){ System.out.println(x); }else if(str.length()
this could also be a good solution, easiest one in short of problems :') n = int(input()) a = 10 ** (n-1) b = 10 ** (n) k = int(math.ceil(pow(a, 1/n))) ans = 0 while(k ** n < b): ans += 1 print(k ** n) k += 1
Shortest code in the list of problems
Shortest code in the list of problems
n=int(input()) for x in range(2,11): if len(str(x*n))==n: print(x*n)