You are viewing a single comment's thread. Return to all comments →
Hope it helps!
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(); long sum=0; for(int i=10;i<n;i++) { long big=0; String str=i+""; for(int j=0;j<str.length();j++) { big+=fact(Integer.valueOf(str.charAt(j)+"")); } if(big%i==0) { sum+=i; } } System.out.println(sum); } static int fact(int i) { if(i==0 || i==1) { return 1; } else { return i*fact(i-1); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #34: Digit factorials
You are viewing a single comment's thread. Return to all comments →
Hope it helps!