Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
17
Task/Magic-constant/Pluto/magic-constant.pluto
Normal file
17
Task/Magic-constant/Pluto/magic-constant.pluto
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
local fmt = require "fmt"
|
||||
|
||||
local magic_constant = |n| -> (n * n + 1) * n / 2
|
||||
|
||||
print("First 20 magic constants:")
|
||||
local mc20 = range(3, 22):map(|n| -> magic_constant(n))
|
||||
for mc20:chunk(10) as chunk do fmt.tprint("%5d", chunk) end
|
||||
|
||||
fmt.print("\n1,000th magic constant: %,s", magic_constant(1002))
|
||||
|
||||
print("\nSmallest order magic square with a constant greater than:")
|
||||
for i = 1, 20 do
|
||||
local goal = 10 ^ i
|
||||
local order = math.floor(math.cbrt(goal * 2)) + 1
|
||||
local len = (i <= 3) ? -3 : (4 <= i <= 9) ? -4 : -2
|
||||
fmt.print($"10%{len}s : %,9s", fmt.super(i), order)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue