Q : Write a program to get Totient number from given number?
[ Totient number = All prime number(M)<given prime number(N)
l.e. N=10
M={1,3,5,7}=4
]
Answer :
/* ::: Girfa :::
http://girfahelp.blogspot.in/p/c-language.html
#include<stdio.h>
#include<conio.h>
void main()
{
int n,p,c,k=0;
clrscr();
printf("Enter number in range>> ");
scanf("%d",&n);
for(p=1;p<=n;p++)
{
for(c=2;c<p;c++)
{
if(p%c==0)
break;
}
if(c==p)
k++;
}
printf("\nTotal Totient is %d",k);
getch();
}
No comments:
Post a Comment