Created
August 13, 2018 16:52
-
-
Save hanjae-jea/74ae2ffc209596a3d88cdfba2217383e to your computer and use it in GitHub Desktop.
0814
This file contains hidden or 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
int sqrt(long long int n){ | |
long long int i; | |
for( i = 0 ; i < n; i ++ ){ | |
if( i*i >= n ) return i; | |
} | |
return 0; | |
} |
This file contains hidden or 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> | |
int n; | |
void f1(int n) | |
{ | |
int ok = 1; | |
for (int i = 2; i<n; i++) { | |
if (n%i == 0) | |
ok--; | |
} | |
if (ok == 1) | |
printf("prime"); | |
else | |
printf("composite"); | |
} | |
void f2(int n) | |
{ | |
int ok = 1; | |
for (int i = 2; i<n; i++) { | |
if (n%i == 0) | |
ok--; | |
} | |
if (ok == 0) | |
// if( ok <= 0 ) | |
printf("composite"); | |
else | |
printf("prime"); | |
} | |
int main() | |
{ | |
scanf("%d", &n); | |
f1(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment