Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int factorial (int n )
- {
- if(n==0)
- return 1;
- else
- return factorial(n-1)*n;
- }
- void factorial (int n ,int &f)
- {
- if(n==0)
- f=1;
- else
- {
- factorial (n-1,f);
- f=f*n; }
- }
- int cmmdc(int a ,int b)
- {
- if(b==0)
- return a;
- else
- return cmmdc(b,a%b);
- }
- int sumcif(int x)
- {
- if(x==0)
- return 0;
- else
- return x%10+sumcif(x/10);
- }
- void sumcif(int n,int &s)
- {
- if(n==0)
- s=0;
- else
- {
- sumcif(n/10,s);
- s=s+n%10;
- }
- }
- int nr_cif_zero(int x)
- {
- if(x>9)
- {
- if(x%10==0)
- return 1+nr_cif_zero(x/10);
- else
- return nr_cif_zero(x/10);
- }
- else
- if(x!=0)
- return 0;
- else
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement