0% found this document useful (0 votes)
17 views

Advip

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Advip

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<math.h>

int ktSNT (const int a)


{
int i = 0;
for(i = 2; i <= (int)sqrt(a); i++)
{
if( a % i == 0)
{
return 0;
}
}
return 1;
}
long long int mod(long long int x, long long int n, long long int d){
long long int tmp = 1;
for(long long int i = 0; i < n; i++){
tmp = (tmp * x) % d;
}
return tmp;
}
int main ()
{
int N,i, k ;
long long int SBD=152;
long long int n=123456;
int a = 0, b = 0, Snt = 0;
printf("\n Nhap vao N:");
scanf("%d", &N);
i = k = N;
i++;
if(ktSNT(i) == 1) a = i;
k--;
if(ktSNT(k) == 1) b = k;
if(abs(a - N) <= abs(b - N))
{Snt = a;}
else {Snt = b;}
printf("So SNT Gan Nhat la: %d\n", Snt);
int r=mod(SBD,Snt,n);
printf ("mod=%d",r);
getch();
return 0;
}

You might also like