20170420, 14:08  #1 
Apr 2017
3_{8} Posts 
What can you do with 2 prime numbers?
Context: I'm teaching a programming class, the students have learned to do objectoriented programming, and I think they know how to program a prime sequence object that has a "nextPrime" method that coughs up the next prime number. (Just simple testing of factors, this is not a number theory class.)
So now I want them to do an exercise that requires having 2 prime number sequences. At first I thought Goldbach, but you can actually do that with just one sequence: you have the number to be tested, a prime, and you test if the difference is a prime. Is there a number theory question (can be trivial, can be hard) that really requires generating pairs of prime numbers? thanks, Victor. 
20170420, 14:48  #2 
Dec 2012
The Netherlands
1765_{10} Posts 
One option would be for them to discover the law of quadratic reciprocity by testing several pairs of primes using their programs and seeing if they can spot the pattern from the results.

20170420, 15:03  #3  
"Forget I exist"
Jul 2009
Dumbassville
2^{3}×1,049 Posts 
Quote:
2a=p+q a=(p+q)/2 aka their arithmetic mean is any whole number value a, the whole numbers have the subset called the prime numbers. so a subset of these say that every prime is equidistant to two other primes. 

20170420, 15:14  #4  
"Rashid Naimi"
Oct 2015
Remote to Here/There
5^{2}·7·13 Posts 
Quote:
For example finding consecutive pair of primes which are any given even number apart? You can make it more out less challenging by setting a minimum value. Last fiddled with by a1call on 20170420 at 15:17 

20170420, 15:31  #5 
"Rashid Naimi"
Oct 2015
Remote to Here/There
5^{2}·7·13 Posts 
Another challenging and interesting utilization of the nextprime would be to find prime gaps of some given minimum size, or their first occurrences.
You can also try asking them to find p such that n! + p is prime for a given n. Leave it up to them to figure out they can start by nextprime(n+1) since anything between 1 and n would give a composite. Last fiddled with by a1call on 20170420 at 15:51 
20170420, 16:00  #6 
"Curtis"
Feb 2005
Riverside, CA
12416_{8} Posts 
Are you saying n! +1 up to n!+n are all composite? I must not understand what you mean by "anything between 1 and n", because there are lots of examples where n!+1 are prime.
Last fiddled with by VBCurtis on 20170420 at 16:02 
20170420, 16:01  #7 
Dec 2014
3·5·17 Posts 
Suggestion
If both objects start at the same value and both go up, then nextPrime() generates
the same values and they do not need two objects. How about this? It is a mathematically nonsense problem but a programming problem. If they extend their class to have a prevPrime() method, then ask them to "make two objects, one generating primes going up from 1, the other generating primes down from 1,000,000 and find the largest sum of the two primes" Primer low(1); Primer high(1000000); while( true ) { int l = low.nextPrime(); int h = high.prevPrime(); if( l > h ) break; // done int sum = l + h; if( sum > ... } 
20170420, 16:24  #8 
"Forget I exist"
Jul 2009
Dumbassville
2^{3}×1,049 Posts 
I think they messed up on saying 1 but we can prove that n!+2 to n!+(nextprime(n+1)1) are all composite. edit:of course this isn't necessarily the first time this gap happens the primorial also works on the same logic: 2*3*5+2 until 2*3*5+(71) are all composite.
Last fiddled with by science_man_88 on 20170420 at 16:29 
20170420, 16:47  #9 
Apr 2017
3 Posts 

20170420, 17:33  #10  
"Rashid Naimi"
Oct 2015
Remote to Here/There
5^{2}·7·13 Posts 
Quote:
What I mean is to find an integer addend (excluding 1, so restricting the addend to primes would also suffice) to a n!, which sum up to a prime. You could start your brute force trial from nextprime(n+1). Any addend m where 1 < m <= n, to n!, would sum up to a composite. Not trying out 1 < m <= n would not be a major time saver but could show up in a measurable fractions of a second faster executions. Please let me know if there are any issues or questions. Last fiddled with by a1call on 20170420 at 18:25 

20170420, 19:58  #11 
Jun 2003
2^{2}×3×449 Posts 

Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Right Perfect Prime Numbers  Housemouse  Math  34  20160407 16:29 
Prime Numbers Or Not  Arxenar  Miscellaneous Math  38  20130628 23:26 
All odd numbers are prime  Citrix  Lounge  5  20100405 21:34 
Old Gem Interview about prime numbers  diep  Lounge  3  20090805 21:01 
Prime numbers  Unregistered  Miscellaneous Math  8  20081109 07:45 