Naive approach: find the sequence of prime numbers 'in the given range' and print the differences between the consecutive ones.Quote:Could you please tell me the logic of printing a prime gap series within a given range

14,362,267 members

See more:

Could you please tell me the logic of printing a prime gap series within a given range i.e. 1 1 2 2 4 2 6....?

**What I have tried:**

int T,N,flag=0,i,j; Scanner scan = new Scanner (System.in); T = scan.nextInt(); N = scan.nextInt(); for(i=T;i <= N; i++) { for(j=2;j

Comments

The code you have provided is incomplete. Please edit your question and show us the actual code you have so far. Because, as is, this just seems like a "write down for me the part of my homework that I did not try to do myself" game. It's not a fun game for us, and it's a dangerous game for you if you are serious about learning development.

That is a mathematics question (and far from clear), not programming. Google will find you lots of white papers on prime numbers.

Naive approach: find the sequence of prime numbers 'in the given range' and print the differences between the consecutive ones.Quote:Could you please tell me the logic of printing a prime gap series within a given range

Comments

Very clever.

Well, it was hard, but eventually I found it! :-D

Quote:Could you please tell me the logic of printing a prime gap series within a given range

Prime is prime numbers. You need to find the list of prime numbers between the 2 given numbers. Aka 000 3 5 7 11 13 17 19 ...

Gap is the difference between 2 concecutive prime numbers in the list

Gap between 3 and 5 is 2

Gap between 5 and 7 is 2

Gap between 7 and 11 is 4

Gap between 11 and 13 is 2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100