# Deficient Number Code?

Printable View

• March 28th, 2012, 10:22 AM
MLeclerc182
Deficient Number Code?
I'm in an introductory java class and need some desperate help on my project. What the code has to do is have the user enter an integer and then it gives the amount of deficient numbers up to that integer. He gave us a similar code shown below that uses prime numbers instead. I don't even know where to start with this or what to change so any help at all would be greatly appreciated. The code he gave us was this:

import java.util.Scanner;
public class Prime
{
public static void main (String[] args)
{
Scanner s = new Scanner(System.in);
int n, f, fcount, p, a;
p = 0;
System.out.print("Enter an integer:");
a = s.nextInt();

for (n = 1; n<=a; n++)
{
System.out.print(n + "\t");
fcount = 0;
for (f = 1; f <= n/2; f++)
if (n % f == 0)
{
System.out.print(f + " ");
fcount++;
}
if (fcount == 1)
p++;
System.out.println();
}
System.out.println("Number of primes = " + p);
}
}
• March 28th, 2012, 10:27 AM
KevinWorkman
Re: Deficient Number Code?
Please don't post multiple copies of the same question. I deleted your duplicate thread. Also, please use the highlight tags when posting code.

Recommended reading: http://www.javaprogrammingforums.com...e-posting.html
• March 28th, 2012, 11:32 AM
Norm
Re: Deficient Number Code?
What is a deficient number?
• March 28th, 2012, 02:57 PM
KevinWorkman
Re: Deficient Number Code?
Quote:

Originally Posted by Norm
What is a deficient number?

Seven. Never liked it much. Also, thirteen is pretty deficient as well.
• March 28th, 2012, 02:59 PM
Norm
Re: Deficient Number Code?
To each his own.