Write a program to find and print the nth element in this sequence
#include <stdio.h>
#include <string.h>
#define N 6666
__int64 dp[N];
int main()
{
int i,j,k,n,r[4]={2,3,5,7};
__int64 min,temp,tp;
dp[1]=1;dp[2]=2;dp[3]=3;dp[4]=4;dp[5]=5;
dp[6]=6;dp[7]=7;dp[8]=8;
for(i=9;i<=5842;i++)
{ tp=i-1;
min=0xffffffffff;
for(j=tp;j>0&&dp[j]*r[3]>dp[tp];j--)//从[1..i-1]中通过乘(2,3,5,7)并取min得第i个数
for(k=0;k<4;k++)
{
temp=dp[j]*r[k];
if(temp>dp[tp]&&temp<min)
min=temp;
}
dp[i]=min;
}
while(scanf("%d",&n),n)
{
if((n%100)/10==1)
printf("The %dth humble number is %I64d.\n",n,dp[n]);
else
{
switch(n%10)
{
case 1:printf("The %dst humble number is %I64d.\n",n,dp[n]);break;
case 2:printf("The %dnd humble number is %I64d.\n",n,dp[n]);break;
case 3:printf("The %drd humble number is %I64d.\n",n,dp[n]);break;
default:printf("The %dth humble number is %I64d.\n",n,dp[n]);break;
}
}
}
return 0;
}