Ok i ran it, it compiles fine, but doesn't print anything so from the code below. SUM never = i..
#include <stdio.h>
int main (void) {
int i, j,SUM=0;
for (i=1;i<10000; i++) {
for (j=1;j<i; j++) {
if((i % j) == 0) {
SUM+= j;
}
if (SUM == i) {
printf("%d", SUM);
}
SUM = 0;
}
return 0;
}
}
int main (void) {
int i, j,SUM=0;
for (i=1;i<10000; i++) {
for (j=1;j<i; j++) {
if((i % j) == 0) {
SUM+= j;
}
}
if (SUM == i) {
printf("%d", SUM);
}
SUM = 0;
}
return 0;
}
wow, it actaully works. Thanks alot guys. Im sorry if I asked alot of questions I just want to understand how it is written and why I was getting errors. Thanks beggerking and JetBlack.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.