Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Print out perfect numbers 0 – 10,000
// Java Coding Challenge - 04: Print out perfect numbers 0 – 10,000 class Rextester { public static boolean isPerfectNumber(int perfect_number) { int temp = 0; for (int i = 1; i <= perfect_number / 2; i++) { if (perfect_number % i == 0) { temp += i; } } if (temp == perfect_number) { return true; } else { return false; } } public static void main(String[] args) { int max = 10_000; for (int i = 1; i <= max; i++) { if (isPerfectNumber(i)) { System.out.print(i + ", "); } } } }
run
|
edit
|
history
|
help
0
PE #4
alphabet
String object comparision
jb14.0 tests
Combination Sum (Leetcode)
Кошачья бойня
1_Arpansubba_Lincoln.java
Palindrome Number in Java
// Java Coding Challenge - 09: Find out duplicate numbers using HashSet
Java Object Info