Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
project euler 12, java
//I can't believe it's just that small import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int num = 0; for (int i = 1; ; i++) { num += i; // num is triangle number i if (countDivisors(num) > 500) { System.out.println(Integer.toString(num)); return; } } } private static int countDivisors(int n) { int count = 0; int end = (int)Math.sqrt(n); for (int i = 1; i < end; i++) { if (n % i == 0) count += 2; } if (n % end == 0) // Perfect square count++; return count; } }
run
|
edit
|
history
|
help
0
Wenfeng Ou
Sumod
contoh 43
Fireball Plugin
Combination Sum (Leetcode)
checkingWord
Coloring map
Quadratic equation
Max palindrome string
Counter.java