Advertisement
CotaIgnorada

calcular factorial + numero invertido

Oct 29th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. int f(int a){
  3.      int result=1,i,num;
  4.     for(i=a;a>=1;a--){
  5.         result=result*a;
  6.     }
  7.     num=dv(result);
  8. return num;
  9. }
  10.  
  11. int dv(int b){
  12.     int n1,n2,n3,num1;
  13.     n1=b%10;
  14.     b=b/10;
  15.     n2=b%10;
  16.     b=b/10;
  17.     n3=b%10;
  18.     n1=n1*100;
  19.     n2=n2*10;
  20.     n3=n3*1;
  21.     num1=n1+n2+n3;
  22. return num1;
  23. }
  24.  
  25. int main(){
  26.     int n,num;
  27.     printf("ingrese un numero\n");
  28.     scanf("%d",&n);
  29.     num=f(n);
  30.     printf("el factorial invertido es: %d\n",num);
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement