1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
|
//Test
#include <iostream>
#include <cstdio>
int main () {
int z=2; // Zahl von der ich die Primfaktoren will
int pf; // Primfaktoren
int a=0; //Anzahl der Primfaktoren bzw Schleifendurchläufe
int i; //Hilfvariable für z
const int MAX = 300;
for (z=2; z<=MAX; z++) {
i = z;
for (pf=2; pf<=i; pf++) {
while (i%pf == 0){ //Zahl durch Primfaktor restlos teilbar?
a++; //Anzahl Primfaktoren erhöhen
i/=pf;
}
}
std::cout<<z<<"\t"<<a<<std::endl;
a=0;
}
return 0;
}
|