// Arup Guha
// 12/2/2026
// Adaptation of PrimeCheck2.java to illustrate a file with 2 classes
// and calling a static method from a different class.

import java.util.*;

public class PrimeCheck3 {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		
		// Read the number.
		System.out.println("What number do you want to check?");
		int n = stdin.nextInt();

		// End message.
		if (MathFunctions.isPrime(n))
			System.out.println(n+" is a prime number.");
		else
			System.out.println(n+" is NOT a prime number.");
		
	} // end main
	
}

class MathFunctions {
	
	// Returns true iff n is prime.
	public static boolean isPrime(int n) {
		
		// First prime number is 2.
		if (n<2) return false;
		
		// Try potential divisors until square root.
		// If any works one works, it's not prime.
		for (int i=2; i*i<=n; i++)
			if (n%i == 0)
				return false;
				
		// If we get here it's prime.
		return true;
	}

	// Returns n factorial, 0 <= n <= 12.
	public static int factorial(int n) {
		int res = 1;
		for (int i=1; i<=n; i++)
			res *= i;
		return res;
	}

	// Returns the number of ways to choose k items out of n
	// 0 <= n <= 12, 0 <= k <= n.
	public static int combination(int n, int k) {
		return factorial(n)/factorial(k)/factorial(n-k);
	}

	// Returns the number of divisors of n.
	public static int numDivisors(int n) {
	
		int res = 0;
		
		// Try each "smaller" divisor.
		for (int i=1; i*i<=n; i++) {
		
			// Found one.
			if (n%i == 0) {
			
				// Count i.
				res++;
				
				// Need to check if we should count n/i.
				if (n/i > i) res++;
			}
		}
		
		return res;
	}

	// Returns the sum of divisors of n.
	public static long sumDivisors(int n) {

		long res = 0;
		
		// Try each "smaller" divisor.
		for (int i=1; i*i<=n; i++) {
		
			// Found one.
			if (n%i == 0) {
			
				// Add i.
				res += i;
				
				// Add n/i if necessary.
				if (n/i > i) res += (n/i);
			}
		}
		
		return res;
	}

	// Returns true if and only if n is a perfect number.
	// A perfect number has its sum of proper divisors equal to
	// itself.
	public static boolean isPerfect(int n) {

		// Just use sumDivisors!
		return sumDivisors(n) == 2*((long)n);
	}
}