import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
ArrayList<Long> lolz = new ArrayList<Long>();
int[] p = {2, 3, 5, 7};
for (int i = 1; i < 11; i++) {
lolz.add((long) i);
}
int index = 0;
while (lolz.size() < 6843) {
long temp = lolz.get(index);
for (int i = 0; i < p.length; i++) {
if (!lolz.contains(temp * p[i])) {
lolz.add(temp * p[i]);
long[] arr = new long[lolz.size()];
for (int j = 0; j < arr.length; j++) {
arr[j] = lolz.get(j);
}
Arrays.sort(arr);
lolz.clear();
for (int j = 0; j < arr.length; j++) {
lolz.add(arr[j]);
}
}
}
index++;
}
long[] arr = new long[lolz.size()];
for (int j = 0; j < arr.length; j++) {
arr[j] = lolz.get(j);
}
while (true) {
int x = Integer.parseInt(br.readLine());
if (x == 0) {
break;
}
String st=getRank(x);
sb.append("The ");
sb.append(x).append(st);
sb.append(" humble number is ");
sb.append(arr[x-1]).append(".\n");
}
System.out.print(sb);
}
static String getRank(int x){
int temp=x%100;
int z=x%10;
if(temp>9 && temp<20){
return "th";
}else{
if(z==1)
return "st";
else if(z==2)
return "nd";
else if(z==3)
return "rd";
else
return "th";
}
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
ArrayList<Long> lolz = new ArrayList<Long>();
int[] p = {2, 3, 5, 7};
for (int i = 1; i < 11; i++) {
lolz.add((long) i);
}
int index = 0;
while (lolz.size() < 6843) {
long temp = lolz.get(index);
for (int i = 0; i < p.length; i++) {
if (!lolz.contains(temp * p[i])) {
lolz.add(temp * p[i]);
long[] arr = new long[lolz.size()];
for (int j = 0; j < arr.length; j++) {
arr[j] = lolz.get(j);
}
Arrays.sort(arr);
lolz.clear();
for (int j = 0; j < arr.length; j++) {
lolz.add(arr[j]);
}
}
}
index++;
}
long[] arr = new long[lolz.size()];
for (int j = 0; j < arr.length; j++) {
arr[j] = lolz.get(j);
}
while (true) {
int x = Integer.parseInt(br.readLine());
if (x == 0) {
break;
}
String st=getRank(x);
sb.append("The ");
sb.append(x).append(st);
sb.append(" humble number is ");
sb.append(arr[x-1]).append(".\n");
}
System.out.print(sb);
}
static String getRank(int x){
int temp=x%100;
int z=x%10;
if(temp>9 && temp<20){
return "th";
}else{
if(z==1)
return "st";
else if(z==2)
return "nd";
else if(z==3)
return "rd";
else
return "th";
}
}
}
No comments:
Post a Comment