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.
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()
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #63: Powerful digit counts
You are viewing a single comment's thread. Return to all comments →
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()