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
some string reverse in java
Info by dfs
Binary Tree ZigZag Traversal
Le saviez-vous ?
Initials
test1
cosmology
LambdaExpression
Filter Iterator
Write a program to sort the odd elements descending order and even elements in ascending order