// bai7.cpp : Defines the entry point for the console application.
// code Du~ng NV
#include"stdafx.h"
#include<conio.h>
#include<stdio.h>
intktsnto(int n)
{
int i;
if(n==0 || n==1) return 0;
for(i=2;i*i<=n;i++) if (n%i==0) return 0;
return1;
}
int_tmain(int argc, _TCHAR* argv[])
{
intn;
printf("\nNhap N= ");
scanf("%d",&n);
if(ktsnto(n)) printf("\n%5d La so nguen to",n);
elseprintf("\n%5d khong phai la so nguen to",n);
getch();
return0;
}
No comments:
Post a Comment