Actually this all what it gets to solve this problem. π π

The Carmichael Numbers within the range given are only 16 numbers, you can pre compute them or actually copy them from The On-Line Encyclopedia of Integer Sequences

but this is cheating don’t do that π here it is the Provoking solution π

the original solution is discussed further below.

import java.util.Arrays;
import java.util.Scanner;
import System.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] ar = { 561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, 29341, 41041, 46657, 52633, 62745, 63973, 75361 };
int n=-1;
while((n =in.nextInt())!=0)
.out.println((Arrays.binarySearch(ar, n) >=0? "The number "+ n + " is a Carmichael number." : n + " is normal."));
}
}

### Like this:

Like Loading...

*Related*