Every whole number from 2 up is a product of prime numbers: 360 = 2 × 2 × 2 × 3 × 3 × 5. PrimeFactors reads a number (at least 2) and prints this decomposition, the number of prime factors, and whether the number is prime.
Method: try the factor 2. While it divides the number, record it and divide; when it no longer divides, move to the next factor. Stop when the number has been reduced to 1. For the input
360
the program prints
360 = 2 x 2 x 2 x 3 x 3 x 5
Number of prime factors: 6
360 is not prime