The Modern C# Challenge
上QQ阅读APP看书,第一时间看更新

11. Primality testing

A prime number is an integer greater than 1 that has no factors other than 1 and itself. For example, 17 is prime because the only positive integers that you can multiply to get 17 are 1 and 17. In contrast, 21 is not prime because 3 × 7 = 21. Integers greater than 1 that are not prime are called composite numbers.

Write a program that determines whether an integer is prime or composite.