Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fibonacci Sequence using Datastage

I'm trying to get an output of Fibonacci sequence in Datastage. I am trying it with a row generator-->Transformer-->Sequential File. My data inside row generator is (0 and 1). I have no idea what to put in my transformer.

Data:0,1

The output should be (0,1,2,3,5,8,13,21,34). The number should be only up to 100, so I'm thinking of a loop variable.

like image 318
user3419715 Avatar asked Dec 06 '25 11:12

user3419715


2 Answers

we can do this using three loop variables.

Name --> Derivation
varSum-->if (@ITERATION=1) then 0 else if (@ITERATION=2) then 1 else varFirst+varSecond
varFirst --> varSecond
varSecond --> varSum.

output will be varSum

from row generator u can get a single row to complete the job.

like image 167
RAJAT BHATHEJA Avatar answered Dec 10 '25 18:12

RAJAT BHATHEJA


Create 4 loop Variables in exact sequence as given below

Variable--> Derivation

Output--> ThirdValue

ThirdValue--> FirstValue + SecondValue

FirstValue--> If @ITERATION = 1 Then InputLink.InputValue Else SecondValue

SecondValue--> ThirdValue

Give this looping condition ---> @ITERATION = 1 Or ThirdValue < 100

Take Output to your output file column

like image 31
Nac_user3432161 Avatar answered Dec 10 '25 17:12

Nac_user3432161



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!