Advertisement
Dragonkoko

facto

Sep 4th, 2013
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int x,l,i,fac=1,j,h,m,sum;
  7.     printf("enter first number \n");
  8.     scanf("%d",&x);
  9.     printf("sequence length\n");
  10.     scanf("%d",&l);
  11.     int ar[l];
  12.     for(i=0;i<x;i++){
  13.         fac = (i+1)*fac;
  14.     }
  15.     ar[0] = fac;
  16.     for(m=0;m<l-1;m++){
  17.         fac = ar[m];
  18.         while (fac=!0){
  19.             fac = fac/10;
  20.             j = j+1;
  21.     }
  22.         int ar2[j];
  23.         for(h=0;h<j;h++){
  24.             ar2[h]= fac%10;
  25.             fac = fac/10;
  26.         }
  27.         for(h=0;h>j;h++){
  28.             for(i=0;i<ar2[h];i++){
  29.                 fac = (i+1)*fac;
  30.             }
  31.             sum = sum + fac;
  32.         }
  33.         ar[m+1]=sum;
  34.     }
  35.     return 0;
  36.     for (i=0;i<l;i++){
  37.         printf("%d",ar[i]);
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement