Home > Back-end >  For help! The for loop while loop instead
For help! The for loop while loop instead

Time:04-11

Looking for n less than the number of close to, if all positive factors and equal to b, b all positive factors and is equal to a, factors including 1 but not including itself, and a is not equal to b, called a, b for close pairs,
Why change the for loop to the while loop is wrong? Close number of
# include & lt; stdio.h>
Int factorsum (int x) {
Int a=1, sum=0;
While (a{if (a==0 x %)
Sum=sum + a;
+;
}
return sum;
}
Int main () {
Int n, I=1, j, m;
The scanf (" % d ", & amp; N);
While (i<=n) {
M=factorsum (I);
For (j=I + 1; J<=n; J++)
{
If (factorsum (j)==i& & M=={j)
Printf (" % d<- & gt; % d \ n ", I, j); }
}
i++;
}
}
  • Related