Advertisement
Farjana_akter

Untitled

Jan 22nd, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int i,j,k,numbr[60000],two=0,three=0,five=0,seven=0,n;
  7. numbr[0]=1;
  8. for(i=1;i<=5900;i++)
  9. {
  10. numbr[i]=min(min(2*numbr[two],3*numbr[three]),min(5*numbr[five],7*numbr[seven]));
  11. // cout<<numbr[i]<<endl;
  12. if(numbr[i]==2*numbr[two])
  13. two++;
  14. if(numbr[i]==3*numbr[three])
  15. three++;
  16. if(numbr[i]==5*numbr[five])
  17. five++;
  18. if(numbr[i]==7*numbr[seven])
  19. seven++;
  20. }
  21. while(cin>>n && n)
  22. {
  23. if(n%10==1 && (n%100)/10!=1)
  24. cout<<"The "<<n<<"st humble number is "<<numbr[n-1]<<"."<<endl;
  25. else if(n%10==2 && (n%100)/10 !=1)
  26. cout<<"The "<<n<<"nd humble number is "<<numbr[n-1]<<"."<<endl;
  27. else if(n%10==3 && (n%100)/10 !=1)
  28. cout<<"The "<<n<<"rd humble number is "<<numbr[n-1]<<"."<<endl;
  29. else
  30. cout<<"The "<<n<<"th humble number is "<<numbr[n-1]<<"."<<endl;
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement