Created
October 25, 2016 04:00
-
-
Save FloydHsiu/a773a230de23db421d42c6003087b63f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
int scale = 0; | |
int i = 0; | |
int j = 0; | |
int is_p = 0; | |
scanf("%d", &scale); | |
//calculate every int lower than scale | |
for(i=2; i<=scale; i++){ | |
//Suppose i is prime number | |
is_p = 1; | |
//Check every number, exclusive of '1', lower than i will not be divisiable | |
for(j=2; j<i; j++){ | |
if(i%j == 0){ | |
//i is divisiable by j, so i is not prime number | |
is_p = 0; | |
break; | |
} | |
} | |
if(is_p == 1){ | |
printf("%d\n", i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment