You are viewing a single comment's thread. Return to all comments →
Hope it Helps!Simple JAVA Solution passes all test cases!!!
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int k=s.nextInt(); int sum=0; for(int i=1;i<n;i++) { if(new StringBuilder(i+"").reverse().toString().equals(i+"") && Integer.toString(i,k).equals(new StringBuilder(Integer.toString(i,k)).reverse().toString())) { sum+=i; } } System.out.println(sum); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #36: Double-base palindromes
You are viewing a single comment's thread. Return to all comments →
Hope it Helps!Simple JAVA Solution passes all test cases!!!