Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/merttalug/perfect-numbers
A program that finds whether a positive number entered by users is a perfect number.
https://github.com/merttalug/perfect-numbers
java kodluyoruz math mathematics maths patika-dev perfect-numbers
Last synced: 1 day ago
JSON representation
A program that finds whether a positive number entered by users is a perfect number.
- Host: GitHub
- URL: https://github.com/merttalug/perfect-numbers
- Owner: merttalug
- License: mit
- Created: 2022-03-23T17:03:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-23T17:08:22.000Z (over 2 years ago)
- Last Synced: 2023-07-14T14:12:22.120Z (over 1 year ago)
- Topics: java, kodluyoruz, math, mathematics, maths, patika-dev, perfect-numbers
- Language: Java
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Perfect Numbers
A program that finds whether a positive number entered by users is a perfect number.## What are the Perfect Numbers ?
A perfect number is a number whose sum of positive integer factors (divisors without a remainder) excluding itself is equal to itself.![img](https://wikimedia.org/api/rest_v1/media/math/render/svg/54ba0eb88722c61bf7d3b5f43693e9d70e588b89)
## Code BLock
```
import java.util.Scanner;public class PerfectNumbers {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int i, num, total = 0;do {
System.out.println("Please enter a positive number : ");
num = input.nextInt();
}
while (num <= 0);for (i = 1; i < num; i++) {
if (num % i == 0) {
total += i;
}
}
if (total == num) System.out.println(num + " is a Perfect Number.");
else System.out.println(num + " is not a Perfect Number.");}
}```