Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int div2(int n)
- {
- int nr=0;
- if(n<2)
- {
- return 0;
- }
- while(n%2==0)
- {
- nr++;
- n=n/2;
- }
- return nr;
- }
- int div5(int n)
- {
- int nr=0;
- if(n<5)
- {
- return 0;
- }
- while(n%5==0)
- {
- nr++;
- n=n/5;
- }
- return nr;
- }
- int main()
- {
- int a,b;
- int nr5=0,nr2=0;
- cin>>a;
- while(a!=0)
- {
- int b;
- int d2=div2(a);
- int d5=div5(a);
- nr2+=d2;
- nr5+=d5;
- cin>>b;
- a=b;
- }
- if(nr2<nr5)
- cout<<nr2;
- else cout<<nr5;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement