Find adjacent primes which differ by a square integer: Difference between revisions

Added Easylang
No edit summary
(Added Easylang)
 
(2 intermediate revisions by 2 users not shown)
Line 438:
</pre>
 
 
=={{header|EasyLang}}==
{{trans|AWK}}
<syntaxhighlight>
fastfunc isprim num .
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
prim = 2
proc nextprim . .
repeat
prim += 1
until isprim prim = 1
.
.
func is_square n .
h = floor sqrt n
return if h * h = n
.
while prim < 1000000
prev = prim
nextprim
if prim - prev > 36 and is_square (prim - prev) = 1
print prim & " - " & prev & " = " & prim - prev
.
.
</syntaxhighlight>
{{out}}
<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>
 
=={{header|F_Sharp|F#}}==
Line 1,053 ⟶ 1,115:
997877 997813 diff = 64
done...
</pre>
 
=={{header|Quackery}}==
 
<code>eratosthenes</code>, <code>isprime</code>, and <code>sqrt</code> are defined at [[Sieve of Eratosthenes#Quackery]].
 
<syntaxhighlight lang="Quackery"> 1000000 eratosthenes
 
0 0
1000000 times
[ i^ isprime if
[ nip i^ 2dup swap -
dup 36 > iff
[ dup sqrt dup * = if
[ 2dup swap
2dup - unrot
echo say " - "
echo say " = "
echo cr ] ]
else drop ] ]
2drop</syntaxhighlight>
 
{{out}}
 
<pre>89689 - 89753 = 64
107377 - 107441 = 64
288583 - 288647 = 64
367957 - 368021 = 64
381103 - 381167 = 64
396733 - 396833 = 100
400759 - 400823 = 64
445363 - 445427 = 64
623107 - 623171 = 64
625699 - 625763 = 64
637003 - 637067 = 64
710713 - 710777 = 64
725209 - 725273 = 64
779413 - 779477 = 64
801883 - 801947 = 64
803749 - 803813 = 64
821677 - 821741 = 64
832519 - 832583 = 64
838249 - 838349 = 100
844777 - 844841 = 64
883807 - 883871 = 64
912103 - 912167 = 64
919447 - 919511 = 64
954763 - 954827 = 64
981823 - 981887 = 64
997813 - 997877 = 64
</pre>
 
Line 1,319 ⟶ 1,431:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int
import "./fmt" for Fmt
 
1,988

edits