In number theory, a prime number is balanced if it is equidistant from the prime before it and the prime after it. It is therefore the arithmetic mean of those primes. For example, 5 is a balanced prime, two units away from 3, and two from 7.211 is 12 units away from the previous prime, 199, and 12 away from the next, 223. A prime that is greater than the arithmetic mean of the primes before and after it is called a strong prime. It is closer to the prime after it than the one before it. For example, the strong prime 17 is closer to 19 than it is to 13 (see note at bottom). A prime that is lesser than the arithmetic mean of the primes before and after it is called weak prime. For example, 19. Create a function that takes a prime number as input and returns "Strong" if it is a strong prime, "weak" if it is a weak prime, or "Balanced". Examples primalStrength (211) primalStrength (17) primalStrength (19) → "Weak" - "Balanced" - "Strong"

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

Answer in JS only

In number theory, a prime number is balanced if it is equidistant from the prime before it and
the prime after it. It is therefore the arithmetic mean of those primes. For example, 5 is a
balanced prime, two units away from 3, and two from 7.211 is 12 units away from the
previous prime, 199, and 12 away from the next, 223.
A prime that is greater than the arithmetic mean of the primes before and after it is called a
strong prime. It is closer to the prime after it than the one before it. For example, the strong
prime 17 is closer to 19 than it is to 13 (see note at bottom).
A prime that is lesser than the arithmetic mean of the primes before and after it is called
weak prime. For example, 19.
Create a function that takes a prime number as input and returns "Strong" if it is a strong
prime, "weak" if it is a weak prime, or "Balanced"
Examples
primalStrength (211)
primalStrength (17)
primalStrength (19) → "Weak"
"Balanced"
- "Strong"
Transcribed Image Text:In number theory, a prime number is balanced if it is equidistant from the prime before it and the prime after it. It is therefore the arithmetic mean of those primes. For example, 5 is a balanced prime, two units away from 3, and two from 7.211 is 12 units away from the previous prime, 199, and 12 away from the next, 223. A prime that is greater than the arithmetic mean of the primes before and after it is called a strong prime. It is closer to the prime after it than the one before it. For example, the strong prime 17 is closer to 19 than it is to 13 (see note at bottom). A prime that is lesser than the arithmetic mean of the primes before and after it is called weak prime. For example, 19. Create a function that takes a prime number as input and returns "Strong" if it is a strong prime, "weak" if it is a weak prime, or "Balanced" Examples primalStrength (211) primalStrength (17) primalStrength (19) → "Weak" "Balanced" - "Strong"
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr