Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int nr, i, ok;
- scanf("%d", &nr);
- while(nr > 0)
- {
- ok = 1; //presupun ca este prim
- for(i = 2 ; i <= nr/2; i++)
- {
- if(nr % i == 0)
- {
- ok = 0; //clar nu este prim
- printf("%d ", i);
- }
- }
- if(ok == 1)
- {
- printf("PRIM\n");
- }
- else
- {
- printf("\n");
- }
- scanf("%d", &nr);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment