Create a function that returns true if there's at least one prime number in the given range (n1 to n2 (inclusive)), false otherwise. Examples primeInRange (10, 15) true // Prime numbers in range: 11, 13 primeInRange (62, 66) false // No prime numbers in range. primeInRange(3, 5) true // Prime numbers in range: 3, 5 Notes n2 is always greater than n1. n1 and n2 are always positive. • 0 and 1 aren't prime numbers.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question
Create a function that returns true if there's at least one prime number in the given range
(n1 to n2 (inclusive)), false otherwise.
Examples
primeInRange (10, 15) true
// Prime numbers in range: 11, 13
primeInRange (62, 66) false
// No prime numbers in range.
primeInRange (3, 5) → true
// Prime numbers in range: 3, 5
Notes
n2 is always greater than n1.
n1 and n2 are always positive.
• 0 and 1 aren't prime numbers.
Transcribed Image Text:Create a function that returns true if there's at least one prime number in the given range (n1 to n2 (inclusive)), false otherwise. Examples primeInRange (10, 15) true // Prime numbers in range: 11, 13 primeInRange (62, 66) false // No prime numbers in range. primeInRange (3, 5) → true // Prime numbers in range: 3, 5 Notes n2 is always greater than n1. n1 and n2 are always positive. • 0 and 1 aren't prime numbers.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning