Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
44
Task/Fibonacci-sequence/TSE-SAL/fibonacci-sequence.tse
Normal file
44
Task/Fibonacci-sequence/TSE-SAL/fibonacci-sequence.tse
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// library: math: get: series: fibonacci <description></description> <version control></version control> <version>1.0.0.0.3</version> <version control></version control> (filenamemacro=getmasfi.s) [<Program>] [<Research>] [kn, ri, su, 20-01-2013 22:04:02]
|
||||
INTEGER PROC FNMathGetSeriesFibonacciI( INTEGER nI )
|
||||
//
|
||||
// Method:
|
||||
//
|
||||
// 1. Take the sum of the last 2 terms
|
||||
//
|
||||
// 2. Let the sum be the last term
|
||||
// and goto step 1
|
||||
//
|
||||
INTEGER I = 0
|
||||
INTEGER minI = 1
|
||||
INTEGER maxI = nI
|
||||
INTEGER term1I = 0
|
||||
INTEGER term2I = 1
|
||||
INTEGER term3I = 0
|
||||
//
|
||||
FOR I = minI TO maxI
|
||||
//
|
||||
// make value 3 equal to sum of two previous values 1 and 2
|
||||
//
|
||||
term3I = term1I + term2I
|
||||
//
|
||||
// make value 1 equal to next value 2
|
||||
//
|
||||
term1I = term2I
|
||||
//
|
||||
// make value 2 equal to next value 3
|
||||
//
|
||||
term2I = term3I
|
||||
//
|
||||
ENDFOR
|
||||
//
|
||||
RETURN( term3I )
|
||||
//
|
||||
END
|
||||
|
||||
PROC Main()
|
||||
STRING s1[255] = "3"
|
||||
REPEAT
|
||||
IF ( NOT ( Ask( " = ", s1, _EDIT_HISTORY_ ) ) AND ( Length( s1 ) > 0 ) ) RETURN() ENDIF
|
||||
Warn( FNMathGetSeriesFibonacciI( Val( s1 ) ) ) // gives e.g. 3
|
||||
UNTIL FALSE
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue