Question
Hi, I'm trying to write C code that will print the odd abundant numbers between 1 and 5000 and I've written a program for it
Hi, I'm trying to write C code that will print the odd abundant numbers between 1 and 5000 and I've written a program for it but it doesn't work. If you would be able to help me fix it or point out where I went wrong that would be awesome.
# include
int main () { int getSum(int n) int i, n, j, sum = 0; /* print initial statement to give context of program*/ printf(" The odd abundant numbers between 1 and 5000 are: "); scanf("%d", &n); /* first declare a range for the integer i*/ for (i=1; 1<=n; i++); {
/* determine each factor for every integer i*/
for (j = 1; j <= i/2; j++) { if (i % j == 0) { sum = sum + j; } } /* print abundant number alone */ if (sum > i) printf("%d ", n);
sum = 0; } /* determine whether integer i is odd*/ if (i % 2 != 0) { /* print all integers that satisfy these requirements*/ printf("%d", n); } printf(" "); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started