Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int fact(int no)
- {
- int res = 1;
- while(no != 1)
- {
- res = res *no;
- no--;
- }
- return res;
- }
- int gcd(int x,int y)
- {
- int m,i;
- if(x>y)
- m=y;
- else
- m=x;
- for(i=m;i>=1;i--){
- if(x%i==0&&y%i==0){
- // printf("nHCF of two number is : %d",i) ;
- break;
- }
- }
- return i;
- }
- int main()
- {
- int n,i,j,k,cnt = 0,fa;
- scanf("%d",&n);
- for(i = 2; i <= n; i++)
- {
- fa = fact(i);
- printf("%dn",fa);
- for(j = 1; j <= (fa/2); j++)
- {
- // printf("%dn",j);
- for(k=2; k <= fa ; k++)
- {
- if(j >k )
- {
- if(((j*k) == fa) && (gcd(j,k) == 1))
- {
- cnt ++;
- // printf("insidet j = %d k = %dn",j,k);
- }
- }
- }
- }
- }
- cnt = cnt + (n-1);
- if(n >1)
- printf("%d",cnt);
- else
- printf("0");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement