+ 1

Write A Program to Find Sum Of Difference between Consecutive Prime Numbers which lie within the input range.

input : 4,20 output : 14 ((7-5)+(11-7) +(13-11)+(17-13)+(19-17)) = (2 + 4 +2 + 4 + 2)

25th Aug 2019, 5:00 PM
Safe Dealzz
Safe Dealzz - avatar
2 Answers
+ 1
I don't know answer someone please attempt this
26th Aug 2019, 5:05 PM
Safe Dealzz
Safe Dealzz - avatar
0
Find all the primes between the given numbers and store them in an array. Run a loop and store the differences between two consecutive numbers in the above array and store them in a other array .Now run a last loop and find out the sum.
27th Aug 2019, 4:24 AM
Kota Lalithaditya
Kota Lalithaditya - avatar