Writing a program in Java that calculates and tabulates the function (deficient,
ID: 3652602 • Letter: W
Question
Writing a program in Java that calculates and tabulates the function (deficient, abundant, perfect, and prime numbers).--The numbe of abudant numbers less than or equal to n, where n =1,2,..., N;
--The number of deficient numbers less than or equal to n, where n=1,2,...,N;
--The number of perfect numbers less than or equal to n, where n=1,2,...,N;
--The number of prime numbers less than or equal to n, where n=1,2,...,N;
If the user enters 20 for N the printout of the tabulation must look like the following:
N Abundand Deficient Perfect Prime
1 0 1 0 0
2 0 2 0 1
3 0 3 0 2
4 0 4 0 2
5 0 5 0 3
6 0 5 1 3
7 0 6 1 4
8 0 7 1 4
9 0 8 1 4
10 0 9 1 4
11 0 10 1 5
12 1 10 1 5
13 1 11 1 6
14 1 12 1 6
15 1 13 1 6
16 1 14 1 6
17 1 15 1 7
18 2 15 1 7
19 2 16 1 8
20 3 16 1 8
Explanation / Answer
import java.util.*; public class calculate { static int sum_divisors(int n) { int sum=0; for(int i=1;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.