Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Magic-constant/Factor/magic-constant.factor
Normal file
17
Task/Magic-constant/Factor/magic-constant.factor
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
USING: formatting io kernel math math.functions.integer-logs
|
||||
math.ranges prettyprint sequences ;
|
||||
|
||||
: magic ( m -- n ) dup sq 1 + 2 / * ;
|
||||
|
||||
"First 20 magic constants:" print
|
||||
3 22 [a,b] [ bl ] [ magic pprint ] interleave nl
|
||||
nl
|
||||
"1000th magic constant: " write 1002 magic .
|
||||
nl
|
||||
"Smallest order magic square with a constant greater than:" print
|
||||
1 0 20 [
|
||||
[ 10 * ] dip
|
||||
[ dup magic pick < ] [ 1 + ] while
|
||||
over integer-log10 over "10^%02d: %d\n" printf
|
||||
dup + 1 -
|
||||
] times 2drop
|
||||
Loading…
Add table
Add a link
Reference in a new issue