Question: 2 Write a Java program given the following specification and provide comments which explain how your algorithm works. Estimate the Big O complexity of your
Write a Java program given the following specification and
provide comments which explain how your algorithm works.
Estimate the Big complexity of your program and explain
your reasoning clearly.
Problem Statement
The goal is to read in a number and output the distance
between the prime number that precedes it and the prime that
follows it If the number itself happens to be prime, then output
the distance to the subsequent prime. For example, if is
then output because the next prime is which is away.
Input Format
An integer
Output Format
The distance between the preceding and subsequent prime
number at
Constraints
Sample Input
Sample Output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
