+ 1
Why my output show 1. I want to print perfect no between 1 to 1000???????
3 Antworten
+ 5
change line 7 to:
for(int j=1;j<i;j++)
a number is always dividable by itself, but that shouldn't be in it's sum.
0
I is 1.
S is 1.
you print 1.
I is 2.
2%1==0 s=1
2%2==0 s=3
No print
I is 3.
3%1==0 s=1
3%2==1 s=1
3%3==0 s=4
No print.
and the numbers keep groing
0
Veerendra Kushwaha
In 7th line remove <= nd put only < as we know that the number always divisible by itself but we study that In program perfect number are those in which sum of their factor excluding itself is equal to d
that number!!!!
But if u hve to do with this only then In line 15 i.e.if(s==i) // divide s by 2 so it wll work fine
// hope u get it