Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main() {
- int i,j,n;
- printf("Enter N (where N is the max number you want prime numbers to): \n");
- scanf("%d", &n);
- printf("Prime numbers: ");
- for(i = 2;i <= n;i++) {
- int c = 0;
- for(j = 1;j <= i;j++) {
- if(i % j == 0) {
- c++;
- }
- }
- if(c == 2) {
- printf("%d ", i);
- }
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement