Question: c programming Lab 5 Q.1 Prime Numbers Description Lab5-1. Prime Number This is an exercise on non-nested definite looping. Write a C program that requests

c programming
Lab 5 Q.1 Prime Numbers

Description

Lab5-1. Prime Number

This is an exercise on non-nested definite looping. Write a C program that requests a positive integer x in the range of 2 to 100 from the user and prints out whether it is a prime number. If x is a prime number, print out "Yes". Otherwise, print out the smallest divisor of x that is greater than 1.

As a reminder, a prime number is an integer greater than 1 that is not divisible by any positive numbers other than 1 or itself. For beginners, a simple method to determine if a number is a prime number is trial by division. In this method, you divide the number x by numbers from 2 to x-1. If x is a prime number, none of them would be a divisor of x.

You will find the modulus operator % essential.

You may assume the user input is always valid.

Deadline: 13 Mar, 2023 (Mon)

Input

A positive integer x in the range of 2 to 100.

Output

If x is a prime number, print out "Yes". Otherwise, print out the smallest divisor of x that is greater than 1.

Sample Input 1

5

Sample Output 1

Yes

Sample Input 2

49

Sample Output 2

7

Sample Input 3

97

Sample Output 3

Yes

Sample Input 4

55

Sample Output 4

5

Sample Input 5

81

Sample Output 5

3

Sample Input 6

13

Sample Output 6

Yes

Hint


Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!