OFFSET
1,1
LINKS
Daniel Suteu, Table of n, a(n) for n = 1..100
EXAMPLE
For n = 6, a(6) = 53, because the next prime after 53 is 59 and the previous prime before 53 is 47, where both have an equal distance of 6 from 53, which is the smallest number with this property.
MATHEMATICA
Table[k = 1; While[Nand[k - n == NextPrime[k, -1], k + n == NextPrime@ k], k++]; k, {n, 41}] (* Michael De Vlieger, Feb 20 2017 *)
PROG
(Perl)
use ntheory qw(:all);
for (my $k = 1 ; ; ++$k) {
for (my $n = 1 ; ; ++$n) {
my $p = prev_prime($n) || next;
my $q = next_prime($n);
if ($n-$p == $k and $q-$n == $k) {
printf("%s %s\n", $k, $n);
last;
}
}
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Daniel Suteu, Feb 20 2017
STATUS
approved