Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Magic-constant/QB64/magic-constant.qb64
Normal file
26
Task/Magic-constant/QB64/magic-constant.qb64
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
$NOPREFIX
|
||||
|
||||
DIM order AS INTEGER
|
||||
DIM target AS INTEGER64
|
||||
|
||||
PRINT "First 20 magic constants:"
|
||||
FOR i = 3 TO 22
|
||||
PRINT USING "####, "; MagicSum(i);
|
||||
IF i MOD 5 = 2 THEN PRINT
|
||||
NEXT i
|
||||
PRINT
|
||||
PRINT USING "1000th magic constant: ##########,"; MagicSum(1002)
|
||||
PRINT
|
||||
PRINT "Smallest order magic square with a constant greater than:"
|
||||
FOR i = 1 TO 13 ' 64-bit integers can take us no further, unsigned or not
|
||||
target = 10 ^ i
|
||||
DO
|
||||
order = order + 1
|
||||
LOOP UNTIL MagicSum(order) > target
|
||||
PRINT USING "10^**: #####,"; i; order
|
||||
order = order * 2 - 1
|
||||
NEXT i
|
||||
|
||||
FUNCTION MagicSum&& (n AS INTEGER)
|
||||
MagicSum&& = (n * n + 1) / 2 * n
|
||||
END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue