Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
29
Task/Fibonacci-sequence/ECL/fibonacci-sequence.ecl
Normal file
29
Task/Fibonacci-sequence/ECL/fibonacci-sequence.ecl
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//Calculates Fibonacci sequence up to n steps using Binet's closed form solution
|
||||
|
||||
|
||||
FibFunction(UNSIGNED2 n) := FUNCTION
|
||||
REAL Sqrt5 := Sqrt(5);
|
||||
REAL Phi := (1+Sqrt(5))/2;
|
||||
REAL Phi_Inv := 1/Phi;
|
||||
UNSIGNED FibValue := ROUND( ( POWER(Phi,n)-POWER(Phi_Inv,n) ) /Sqrt5);
|
||||
RETURN FibValue;
|
||||
END;
|
||||
|
||||
FibSeries(UNSIGNED2 n) := FUNCTION
|
||||
|
||||
Fib_Layout := RECORD
|
||||
UNSIGNED5 FibNum;
|
||||
UNSIGNED5 FibValue;
|
||||
END;
|
||||
|
||||
FibSeq := DATASET(n+1,
|
||||
TRANSFORM
|
||||
( Fib_Layout
|
||||
, SELF.FibNum := COUNTER-1
|
||||
, SELF.FibValue := IF(SELF.FibNum<2,SELF.FibNum, FibFunction(SELF.FibNum) )
|
||||
)
|
||||
);
|
||||
|
||||
RETURN FibSeq;
|
||||
|
||||
END; }
|
||||
Loading…
Add table
Add a link
Reference in a new issue