Find adjacent primes which differ by a square integer: Difference between revisions
Content added Content deleted
(Added Go) |
(→{{header|Perl}}: fixed code and output) |
||
Line 645: | Line 645: | ||
<lang perl>#!/usr/bin/perl |
<lang perl>#!/usr/bin/perl |
||
use strict; # https://rosettacode.org/wiki/Find_adjacents_primes_which_difference_is_square_integer |
use strict; # https://rosettacode.org/wiki/Find_adjacents_primes_which_difference_is_square_integer |
||
use warnings; |
use warnings; |
||
use ntheory qw( primes is_square ); |
use ntheory qw( primes is_square ); |
||
my $primeref = primes( |
my $primeref = primes(1e6); |
||
for my $i (1 .. $#$primeref |
for my $i (1 .. $#$primeref) { |
||
⚫ | |||
{ |
|||
is_square($diff) and print "$primeref->[$i] - $primeref->[$i - 1] = $diff\n"; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
89753 - 89689 = 64 |
|||
107441 - 107377 = 64 |
|||
288647 - 288583 = 64 |
|||
368021 - 367957 = 64 |
|||
381167 - 381103 = 64 |
|||
396833 - 396733 = 100 |
|||
400823 - 400759 = 64 |
|||
445427 - 445363 = 64 |
|||
623171 - 623107 = 64 |
|||
625763 - 625699 = 64 |
|||
637067 - 637003 = 64 |
|||
710777 - 710713 = 64 |
|||
725273 - 725209 = 64 |
|||
779477 - 779413 = 64 |
|||
801947 - 801883 = 64 |
|||
803813 - 803749 = 64 |
|||
821741 - 821677 = 64 |
|||
832583 - 832519 = 64 |
|||
838349 - 838249 = 100 |
|||
844841 - 844777 = 64 |
|||
883871 - 883807 = 64 |
|||
912167 - 912103 = 64 |
|||
919511 - 919447 = 64 |
|||
954827 - 954763 = 64 |
|||
981887 - 981823 = 64 |
|||
997877 - 997813 = 64 |
|||
</pre> |
</pre> |
||