Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- int zahl, i, j;
- int isPrim;
- int breakAndCalc;
- scanf("%d", &zahl);
- if(zahl < 2)
- {
- printf("%d kann nicht zerlegt werden.\n", zahl);
- }
- else
- {
- // search from 2 up tu {zahl}
- // if {zahl} is a prim number -> break the for loop (isPrim)
- // if {zahl} is a NON prim number -> break the loop (breakAndCalc)
- for (j = 2; j <= zahl && isPrim == 0 breakAndCalc == 0;j++)
- {
- // true if prim number
- if (j == zahl)
- {
- isPrim++;
- printf("%d ist prim.\n", zahl);
- }
- else
- // true if a non prim number
- if (zahl % j == 0)
- {
- breakAndCalc++;
- printf("%d ist keine prim.\n", zahl);
- }
- }
- // true if non prim number
- if (breakAndCalc != 0)
- {
- for(i=2 ; i <= zahl ; i++)
- {
- if(zahl % i == 0)
- {
- zahl = zahl / i;
- printf("%d\n", i);
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement