Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int vuelta (int y);
- int factorialV(int x);
- int main(){
- int input;
- printf ("Ingrese un nΓΊmero para calcular su factorial invertido:\n");
- scanf ("%d", &input);
- //printf ("El factorial corresponde a: %.0f\n", factorial(input));
- printf ("El factorial invertido corresponde a: %d\n", factorialV(input));
- return 0;
- }
- int factorialV(int x){
- int i,temp;
- int fact;
- temp=x-1;
- fact=x;
- if(x>=1){
- for(i=temp;i>=1;i--){
- fact*=temp;
- temp-=1;
- }
- }
- else if(x==0){
- fact=1;
- }
- fact=vuelta(fact);
- return fact;
- }
- int vuelta(int y){
- int rest,inv=0;
- while(y!=0){
- rest=y%10;
- y=y/10;
- inv=inv*10+rest;
- }
- return inv;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement