Prime numbers p for which the sum of primes less than or equal to p is prime: Difference between revisions

Added Uiua solution
(Added Quackery.)
(Added Uiua solution)
 
(3 intermediate revisions by 3 users not shown)
Line 299:
 
=={{header|J}}==
<syntaxhighlight lang="j">(+#~ 1: p: +/\)@(i.&.(p:^:_1)) 1000</syntaxhighlight>
{{out}}
<pre>2 3 7 13 37 43 281 311 503 541 557 593 619 673 683 733 743 839 881 929 953</pre>
Line 729:
Found 21 numbers
done...
</pre>
 
=={{header|RPL}}==
{{works with|HP|49}}
« { } 0 0
'''WHILE''' DUP 1000 < '''REPEAT'''
NEXTPRIME SWAP OVER + SWAP
'''IF''' OVER ISPRIME? '''THEN''' ROT OVER + UNROT '''END'''
'''END''' DROP2
» '<span style="color:blue">TASK</span>' STO
{{out}}
<pre>
1: { 2 3 7 13 37 43 281 311 503 541 557 593 619 673 683 733 743 839 881 929 953 }
</pre>
 
Line 766 ⟶ 779:
prime: 929 prime sum: 66463
prime: 953 prime sum: 70241
</pre>
 
=={{header|Uiua}}==
{{works with|Uiua|0.10.0-dev.1}}
<syntaxhighlight lang="Uiua">
# Build primes by sieve. Limit found by inspection.
⇌◌⍢(▽≠0◿⊃⊢(.↘1)⟜(⊂⊢)|>0⧻) ↘2⇡80000 []
# Build running sums.
\+▽<1000...
# # Find sums that are prime, then prettify.
⧻.⍉⊟:∩(⬚0▽),⟜∊
 
</syntaxhighlight>
{{out}}
<pre>
╭─
╷ 2 2
3 5
7 17
13 41
37 197
43 281
281 7699
311 8893
503 22039
541 24133
557 25237
593 28697
619 32353
673 37561
683 38921
733 43201
743 44683
839 55837
881 61027
929 66463
953 70241
21
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-seq}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int, Nums
import "./seqfmt" for LstFmt
import "/fmt" for Fmt
 
var primes = Int.primeSieve(1000, true)
Line 786 ⟶ 836:
}
System.print("Primes 'p' under 1000 where the sum of all primes <= p is also prime:")
Fmt.tprint("$4d", results, 7)
for (chunk in Lst.chunks(results, 7)) Fmt.print("$4d", chunk)
System.print("\nFound %(results.count) such primes.")</syntaxhighlight>
 
60

edits