Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // modification of the original code
- #include <stdio.h>
- int main()
- {
- int n;
- printf("Enter the maximum number ");
- scanf("%d", &n);
- printf("Prime numbers are: ");
- for (int i = 2; i <= n; i++) {
- int fact = 0;
- for (int j = 2; j < i; j++)
- if (i%j == 0)
- fact++;
- if (fact == 0)
- printf("%d ", i);
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement