#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
using namespace std;
int a[5850];
int main()
{
//int a[5850];
int n=1;
int p2,p3,p5,p7;
p2=p3=p5=p7=1;
a[1]=1;
while(n<5850)
{
a[++n]=min(min(2*a[p2],3*a[p3]),min(5*a[p5],7*a[p7]));
if(a[n]==2*a[p2]) p2++;
if(a[n]==3*a[p3]) p3++;
if(a[n]==5*a[p5]) p5++;
if(a[n]==7*a[p7]) p7++;
}
while(scanf("%d",&n)&&n)
{
printf("The %d",n);
int ten=n/10%10;
if(n%10==1&&ten!=1) printf("st");
else if(n%10==2&&ten!=1) printf("nd");
else if(n%10==3&&ten!=1) printf("rd");
else printf("th");
printf(" humble number is %d.\n",a[n]);
}
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
using namespace std;
int a[5850];
int main()
{
//int a[5850];
int n=1;
int p2,p3,p5,p7;
p2=p3=p5=p7=1;
a[1]=1;
while(n<5850)
{
a[++n]=min(min(2*a[p2],3*a[p3]),min(5*a[p5],7*a[p7]));
if(a[n]==2*a[p2]) p2++;
if(a[n]==3*a[p3]) p3++;
if(a[n]==5*a[p5]) p5++;
if(a[n]==7*a[p7]) p7++;
}
while(scanf("%d",&n)&&n)
{
printf("The %d",n);
int ten=n/10%10;
if(n%10==1&&ten!=1) printf("st");
else if(n%10==2&&ten!=1) printf("nd");
else if(n%10==3&&ten!=1) printf("rd");
else printf("th");
printf(" humble number is %d.\n",a[n]);
}
return 0;
}