Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Recall that an integer is called prime if its only divisors are 1 and the number itself. The first few primes are: 2, 3, 5,
Recall that an integer is called prime if its only divisors are 1 and the number itself. The first few primes are: 2, 3, 5, 7, and 11 (1 is not considered to be prime).
Write a program that prints (to a file) the first n primes, where n is input by the user. Your program must utilize the function is prime() shown in the solutions6.txt file.
For marking purposes run your program with n = 9. Your program output should look like:
count prime ------- -------
12 23 35 47 5 11 6 13 7 17 8 19 9 23
Note that the tricky part of testing whether an integer is prime has been coded for you in the function is prime. See solutions6.txt for the code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started