Question: Create a program that will input a positive integer from the user. The program should check to make sure the entry is a positive integer
Create a program that will input a positive integer from the user. The program should check to make sure the entry is a positive integer and then check to see if the number is a prime number. A prime number is a number that is divisible only by itself and 1. The first five prime numbers are 2, 3, 5, 7, and 11; you can check this directly from the definition. If the number is prime, the program should display a message to this effect. If the number is not prime, the program should display the number and its factors. For example, if the user enters the number 3, the output should be:
The number 3 is a prime number.
However, if the user enters the number 6, the output should be:
The number 6 is not a prime number.
The factors of 6 are: 1, 2, 3, 6
Step by Step Solution
3.48 Rating (168 Votes )
There are 3 Steps involved in it
include i... View full answer
Get step-by-step solutions from verified subject matter experts
