Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
#include <flow.h>
|
||||
#include <flow-flow.h>
|
||||
|
||||
DEF-MAIN(argv,argc)
|
||||
CLR-SCR
|
||||
SET( amount, 1200 )
|
||||
DIM(amount) AS-ONES( Stern )
|
||||
|
||||
/* Generate Stern-Brocot sequence: */
|
||||
GOSUB( Generate Sequence )
|
||||
PRNL( "Find 15 first: ", [1:19] CGET(Stern) )
|
||||
|
||||
/* show Stern-Brocot sequence: */
|
||||
SET( i, 1 ), ITERATE( ++i, LE?(i,10), \
|
||||
PRN( "First ",i," at "), {i} GOSUB( Find First ), PRNL )
|
||||
PRN( "First 100 at "), {100} GOSUB( Find First ), PRNL
|
||||
|
||||
/* check GCD: */
|
||||
ODD-POS, CGET(Stern), EVEN-POS, CGET(Stern), COMP-GCD, GET-SUMMATORY, DIV-INTO( DIV(amount,2) )
|
||||
|
||||
IF ( IS-EQ?(1), PRNL("The GCD of every pair of adjacent elements is 1"),\
|
||||
PRNL("Stern-Brocot Sequence is wrong!") )
|
||||
END
|
||||
|
||||
RUTINES
|
||||
|
||||
DEF-FUN(Find First, n )
|
||||
RET ( SCAN(1, n, Stern) )
|
||||
|
||||
DEF-FUN(Generate Sequence)
|
||||
SET(i,2)
|
||||
FOR( LE?(i, DIV(amount,2)), ++i )
|
||||
[i] GET( Stern ), [ MINUS-ONE(i) ] GET( Stern ), ADD-IT
|
||||
[ SUB(MUL(i,2),1) ] CPUT( Stern )
|
||||
[i] GET( Stern ), [MUL(i,2)] CPUT( Stern )
|
||||
NEXT
|
||||
RET
|
||||
Loading…
Add table
Add a link
Reference in a new issue