taeyounkim LOG
Code to sort out Prime numbers 본문
728x90
#include <stdio.h>
int main()
{
int d, n;
printf("Enter a number: ");
scanf("%d", &n);
for (d=2 ; d<n ; d++){
if(n%2==0)
break;
}
if(d<n)
printf("%d is divisible by %d", n, d);
else
printf("%d is a prime number", n);
return 0;
}
728x90
'Career&Study > Coding Practice' 카테고리의 다른 글
function that returns the k(th) digit(from the right) in n(a positive integer) (0) | 2021.06.30 |
---|---|
function that returns the day of year (0) | 2021.06.30 |
New Coding Fact_Converting a letter to upper case (0) | 2021.06.13 |
Code that prints a one-month calendar (0) | 2021.06.12 |
Checkbook Balance Program (0) | 2021.06.12 |