Hello all!! i have to make a program for my university that generates 3000 random numbers and finds the one who are powerful! I have written all of the code but i don't know what condition is wrong! let me show you... :-P
for (l=4 ; l < COMPUTATIONS ; l++){
x=l;
m=3;
k=0;
z=x;
while (x%2==0){
x=x/2;
k=k+1;}
while ((m*m<=x) && (k!=1)){
k=0;
while (x%m==0){
x=x/m;
k=k+1;
}
m=m+2;}
if (k>1){
printf ("%d is powerful\n",z);
I do this to find the numbers from 4 to 1000 that are powerful and compare them with http://en.wikipedia.org/wiki/Powerful_number
My results:
4 is powerful
8 is powerful
9 is powerful
12 is powerful
16 is powerful
20 is powerful
24 is powerful
25 is powerful
27 is powerful
28 is powerful
32 is powerful
36 is powerful
40 is powerful
45 is powerful
48 is powerful
49 is powerful
56 is powerful
63 is powerful
64 is powerful
72 is powerful
80 is powerful
81 is powerful
96 is powerful
99 is powerful
100 is powerful
.
.
.
.
It seem that my code finds more numbers powerful that aren't!
Any suggestion would be welcome!! Thanks!!