ive done the main parts... but i dont get how to calculate the number of prime numbers in between. for instance if the input is 8 and 2, the prime numbers will be 7,5,3,2. i want to output "There are __ prime numbers between"
I believe increment should be used, but where do i put it ?
Yes. its a series of elements of the same type placed in contiguous memory locations which can be individually referenced by adding an index to a unique identifier via the use of []?
How would i store the prime numbers found? what does the requirement mean? does it mean to save the prime numbers ? but why would the program want to do that if the input will be changed everytime it runs?
you can save time by re-use the primes saved in the array.
Example:
- User asks for primes in range [2,8]
loop range [2,8] (7 iters)
save {2,3,5,7}
answer: 4
- User asks for primes in range [4,20]
loop range [9,20] (12 iters instead of [4-20] which is 15 iters --> save 3 iters)
answer: 6
save {2,3,5,7,11,13,17,19}
- User asks for primes in range [3,16]
loop range: none0 iter --> faster than 14 iters
answer: 5
save {2,3,5,7,11,13,17,19}
- User asks for primes in range [1, 10 000 000]
loop range: [21, 100 000] ~ 10mil iters, not saving much time here...
answer: N
save {2,3,5,7,11,13,17,19,...,999983}
- User asks for primes in range [1, 9 000 000]
loop range: none0 iter --> super fast, saved 9mil iters!
answer: n
save {2,3,5,7,11,13,17,19,...,999983}