I'm in college and I have to do an assignment on Abundant Numbers (Programmed in C).
Assignment Details are pretty straight forward. Ask for a number determine if it is abundant.
-Use "boolean" function to test a number for abundance.
-use a function to control output and another for input.
-An Abundant Number is a positive integer whose integer factors less than itself sum to a value greater than it.
This is the Code I have so far:
Could someone help me figure out why it declares everything as not an abundant number?
int Input(int N)
printf("Enter the Nth Abundant Number you wish to see: ");
int Calc(int N)
int Sum, I, I2;
Sum = 0;
I2 = sqrt(N);
for (I = 1; I >= I2; I++)
if ((N % I) = 0) Sum += I + (N / I);
int Check(int N, int Sum, int Abundancy)
if (Sum > N)
Abundancy = 1;
Abundancy = 0;
int Output(int Number, int Abundancy)
if (Abundancy == 1)
printf("%d %s", Number, "is Abundant");
printf("%d %s", Number, "is not Abundant");
/* Variables */
int N, Sum;
/* Start Loop */
while (N != 0)
/* Input */
N = Input(N);
for(int I = N; I = (N - 10)or I <= 0; I--)
/* Calculate */
Sum = Calc(N);
/* Determine Abundancy */
Abundancy = Check(N, Sum, Abundancy);
/* Output */
my test is 12. 1 + 2 + 3+ 4+ 6 = 16, 16 > 12, so it is abundant.