Đề: VCT phân tích 1 số nguyên N thành các thừa SNT.
Giải
#include"stdio.h"
#include"conio.h"
int ktsnt(int n)
{
____ int i;
____ if(n<2) return 0;
____ {
________ for(i=2;i<=(n-1);i++)
________ {
________ if(n%i==0) return 0;
________ }
____ return 1;
____ }
}
void main()
{
____ int n,i;
____ printf("Nhap n=");
____ scanf("%d",&n);
____ if(n<2) return ;
____ i=2;
____ while(n!=1)
____ {
________ while(n%i==0)
________ {
____________ printf("%d.",i);
____________ n=n/i;
________ }
________ i++;
________ while(ktsnt(i)==0) i++;
____ }
____ getch();
____ clrscr();
}