June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,21 @@
USING: generalizations io kernel math math.functions
math.primes.factors math.ranges prettyprint sequences ;
IN: rosetta-code.arithmetic-rational
2/5 ! literal syntax 2/5
2/4 ! automatically simplifies to 1/2
5/1 ! automatically coerced to 5
26/5 ! mixed fraction 5+1/5
13/178 >fraction ! get the numerator and denominator 13 178
8 recip ! get the reciprocal 1/8
! ratios can be any size
12417829731289312/61237812937138912735712
8 ndrop ! clear the stack
! arithmetic works the same as any other number.
: perfect? ( n -- ? )
divisors rest [ recip ] map-sum 1 = ;
"Perfect numbers <= 2^19: " print
2 19 ^ [1,b] [ perfect? ] filter .