Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C - Program with no iostream Write a program that tests a sequence numbers if they are primes or not. A positive integer n (n

C - Program with no iostream

Write a program that tests a sequence numbers if they are primes or not. A positive integer n (n > 1) is called prime if it cannot be written as a product of two other positive integers a and b (n = a b) such that neither a or b is equal to 1 or n.

Given a list of integers greater than 1, your task it test each of them and report that they are either primes, or if they are not primes print a factorization of them, i.e., the numbers a and b such that n = a b with 1

Input

The input consists of a sequence of integers, one integer per line. All integers will be greater than 1, except the very last integer, which will be less or equal to 1.

Output

For each integer n in the input, except the last one, you need to either report that n is prime or not. Do not print anything for the last integer, which is less or equal then 1. Actually, once you read an integer that is less or equal to 1, your program should end. For each integer n read in the input, your program must print one line, which must be either n is a prime or n = a * b, where n = a b and a is an integer greater than 1 and as small as possible.

Note that there is exactly one space used between words and characters = and *.

sample input

image text in transcribed

Sample Input Sample Output Sample Output, with visualized whitespace 2 2 is a prime | 2.is.a.prime prime prime | 11.is.a.prime | 29.is.a.prime a 29 30 27 25 595 a 30.2..*..15 2739 30 2 * 15 27 = 3 * 9 25 = 5 * 5 595 = 5 * 119 | 595-=-5-*-119

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions