# You are given a function called is_prime  which consumes a positive number and returns True if the number is prime and False if the number is not prime.  You do not need to write the is_prime function - it is already pre-defined.Your task is to use the Design Recipe to write a main function, that consumes no parameters, which prompts the user for a positive integer, n, and displays the first n primes. Your main function should call the is_prime function. Include a docstring!

Question
192 views

You are given a function called is_prime  which consumes a positive number and returns True if the number is prime and False if the number is not prime.  You do not need to write the is_prime function - it is already pre-defined.

Your task is to use the Design Recipe to write a main function, that consumes no parameters, which prompts the user for a positive integer, n, and displays the first primes. Your main function should call the is_prime function. Include a docstring!

check_circle

Step 1

Before solving this question first, you should know some functions definitions :

Prime number: Primary numbers are two-factor numbers, one and the number itself. The two variables could split it equally. For example, 7 is a prime number that can be divided by only 1 and 7.If we divide 7 by any other number, a fraction value will be  generated. A composite number, which has more than two variables, is the contradictory component of a prime number. We have encountered many types of numbers in   the number system, the most important of which are prime and composite numbers.

isprime():This simple function isprime(number) checks whether the number given is a prime number and returns either True or False? The method guarantees that the number is a positive integer and that 1 is not a prime number?

range():The function range is a builtin function in Python and returns an object of range.

counter: A counter is a container that records how many times it adds identical values.

So following variables , strings , functions are used to solve this problem:

Variables: i , n

Functions: range() , str() , main() .

Step 2

Following steps, a user must be followed to print the prime number:

1. Taking the input from the user.
2. Check whether the input is prime or not.
3. Taking the range function to print the number till user enter the value.
4. Print the numbers of primes numbers only contains po...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in