Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int i,j,k,numbr[60000],two=0,three=0,five=0,seven=0,n;
- numbr[0]=1;
- for(i=1;i<=5900;i++)
- {
- numbr[i]=min(min(2*numbr[two],3*numbr[three]),min(5*numbr[five],7*numbr[seven]));
- // cout<<numbr[i]<<endl;
- if(numbr[i]==2*numbr[two])
- two++;
- if(numbr[i]==3*numbr[three])
- three++;
- if(numbr[i]==5*numbr[five])
- five++;
- if(numbr[i]==7*numbr[seven])
- seven++;
- }
- while(cin>>n && n)
- {
- if(n%10==1 && (n%100)/10!=1)
- cout<<"The "<<n<<"st humble number is "<<numbr[n-1]<<"."<<endl;
- else if(n%10==2 && (n%100)/10 !=1)
- cout<<"The "<<n<<"nd humble number is "<<numbr[n-1]<<"."<<endl;
- else if(n%10==3 && (n%100)/10 !=1)
- cout<<"The "<<n<<"rd humble number is "<<numbr[n-1]<<"."<<endl;
- else
- cout<<"The "<<n<<"th humble number is "<<numbr[n-1]<<"."<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement