Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
USING: formatting fry grouping kernel math math.primes
|
||||
math.statistics sequences ;
|
||||
IN: rosetta-code.successive-prime-differences
|
||||
|
||||
: seq-diff ( seq diffs -- seq' quot )
|
||||
dup [ length 1 + <clumps> ] dip '[ differences _ sequence= ]
|
||||
; inline
|
||||
|
||||
: show ( seq diffs -- )
|
||||
[ "...for differences %u:\n" printf ] keep seq-diff
|
||||
[ find nip { } like ]
|
||||
[ find-last nip { } like ]
|
||||
[ count ] 2tri
|
||||
"First group: %u\nLast group: %u\nCount: %d\n\n" printf ;
|
||||
|
||||
: successive-prime-differences ( -- )
|
||||
"Groups of successive primes up to one million...\n" printf
|
||||
1,000,000 primes-upto {
|
||||
{ 2 }
|
||||
{ 1 }
|
||||
{ 2 2 }
|
||||
{ 2 4 }
|
||||
{ 4 2 }
|
||||
{ 6 4 2 }
|
||||
} [ show ] with each ;
|
||||
|
||||
MAIN: successive-prime-differences
|
||||
Loading…
Add table
Add a link
Reference in a new issue