You are viewing a single comment's thread. Return to all comments →
JavaCode
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { int[] facts = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880}; Scanner s = new Scanner(System.in); int N = s.nextInt(); int count = 0; for (int i = 10; i <= N; i++) { int number = i; int sum = 0; while (number != 0) { int temp = number % 10; sum += facts[temp]; number /= 10; } if (sum % i == 0) { count+=i; } } System.out.println(count); } }
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 →
JavaCode