Kod: Zaznacz cały
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
long long losuj(void) {
return rand() + 2.0;
}
int main(void)
{
srand((unsigned) time(NULL));
long long n=losuj();
long long koniec=ceil(sqrt (n));
int A[koniec];
int i=0;
int k=2;
while(i<koniec) {
A[i]=1;
i++;
}
i=2;
while(i<koniec) {
if(A[i]==1) {
while(i*k<koniec) {
A[i*k]=0;
k++;
}
}
else i++;
k=2;
}
i=0;
printf("%lld = ", n);
while(A[i]!=0)
while(n % A[i]==0) {
printf("%d * ", A[i]);
i++;
}
return 0;
}
Dodano po 23 godzinach 59 minutach 22 sekundach:
Temat do usunięcia