Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
25
Task/Magic-constant/ANSI-BASIC/magic-constant.basic
Normal file
25
Task/Magic-constant/ANSI-BASIC/magic-constant.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
100 REM Magic constant
|
||||
110 DECLARE EXTERNAL FUNCTION A
|
||||
120 DECLARE EXTERNAL FUNCTION InvA
|
||||
130 PRINT "The first 20 magic constants are";
|
||||
140 FOR N = 1 TO 20
|
||||
150 PRINT A(N);
|
||||
160 NEXT N
|
||||
170 PRINT
|
||||
180 PRINT "The 1,000th magic constant is"; A(1000)
|
||||
190 LET E = 1
|
||||
200 FOR N = 1 TO 20
|
||||
210 LET E = E * 10
|
||||
220 PRINT "10^";
|
||||
230 PRINT USING "##: #########": N, InvA(E)
|
||||
240 NEXT N
|
||||
250 END
|
||||
260 REM Returns the magic constant of a magic square of order N + 2
|
||||
270 EXTERNAL FUNCTION A(N)
|
||||
280 LET N2 = N + 2
|
||||
290 LET A = IP((N2 * ((N2 * N2) + 1)) / 2)
|
||||
300 END FUNCTION
|
||||
310 REM Returns the order of the magic square whose magic constant is at least X
|
||||
320 EXTERNAL FUNCTION InvA(X)
|
||||
330 LET InvA = IP((2 * X) ^ (1 / 3)) + 1
|
||||
340 END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue