Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3: Counting Prime Numbers [100 marks] Programming language: Python A prime number is an integer number greater than 1 that is not a product

Question 3: Counting Prime Numbers [100 marks]

Programming language: Python

A prime number is an integer number greater than 1 that is not a product of two smaller integer numbers. In other words, a prime number has only two positive divisors: one and itself. Examples of prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. Do you know during history scientists have always been looking for mysterious properties of prime numbers? Do you know one of the Millennium Prize Problems is about the distribution of prime numbers? Well, if this introduction motivated you enough, now, it is time to write a program about prime numbers.

In this part of the assignment, you are asked to create a program, called PrimeFinder, to count the number of prime numbers in a sequence of numbers provided by the user. PrimeFinder should work as follows:

First, PrimeFinder should ask how many numbers the user has decided to pass to PrimeFinder using the message 'How many numbers do you want to check? '. Lets call the provided number by user n.

For n times PrimeFinder should print 'Enter a positive integer: ' and take a positive integer from the user.

For each prime number, PrimeFinder prints out 'X is a prime number.' where X is the number provided by the user in that round.

For each nonprime number PrimeFinder does not print out a message.

PrimeFinder assumes that its users are smart enough not to enter a float number.

If the user inserts a negative number PrimeFinder should ignore it and inform the user by the message 'PrimeFinder ignores negative numbers!'. For instance, if n=2 the user-provided sequence of numbers can be 3, 5 or 2, -4, -7, 5. In other words, PrimeFinder will continue working until it gets exactly n positive integers.

Finally, PrimeFinder prints out the total count of prime numbers received from the user, Y , in the following format: 'Total prime numbers: Y'.

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_2

Step: 3

blur-text-image_3

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What is the effect of word war second?

Answered: 1 week ago