Write a program to find and print the nth element in this sequence
#include<stdio.h>
#include<math.h>
int main(){
long long data[5848];
int index=1,first=1,second=1,third=1,forth=1,n;
while(1){
if(index==5843)
break;
data[1]=1;
int temp,temp1,temp2;
temp1=data[first]*2<=data[second]*3?data[first]*2:data[second]*3;
temp2=data[third]*5<=data[forth]*7?data[third]*5:data[forth]*7;
temp=temp1<=temp2?temp1:temp2;
if(temp==data[first]*2)
first++;
if(temp==data[second]*3)
second++;
if(temp==data[third]*5)
third++;
if(temp==data[forth]*7)
forth++;
if(temp>data[index]){
//printf("%d ",data[index]);
data[++index]=temp;
}
}
while(~scanf("%d",&n)){
if(n==0)break;
if(n%10==1&&n%100!=11){
printf("The %dst humble number is %d.
",n,data[n]);
}else if(n%10==2&&n%100!=12){
printf("The %dnd humble number is %d.
",n,data[n]);
}else if(n%10==3&&n%100!=13){
printf("The %drd humble number is %d.
",n,data[n]);
}else{
printf("The %dth humble number is %d.
",n,data[n]);
}
}
return 0;
}