public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> primos = numerosPrimos(51);
		do{
			int n = scan.nextInt();
			if(n==0)
				break;
			BigInteger ans = BigInteger.ONE;
			for (int i = 0; i < primos.size(); i++) {
				int current = primos.get(i);
				if(current>n)
					break;
				ans = ans.multiply(new BigInteger(current+""));
			}
			System.out.println(ans);
		}while(scan.hasNext());
	}