I am trying to figure out to produce the first n digits of the Fibonacci sequence but in the form of a Do and While Loop.
I understand that we can define the Fibonacci sequence in the form of a recursive function where f[1] = 1 ; f[2] = 1; f[n_] := f[n] = f[n - 1] + f[n - 2]
How do I put this into a do and while loop to yield the first n terms of the sequence?
Why do you want a loop? Mathematica offers far more elegant solutions. Ok, you could do it like this
n = 15; x = 1; y = 1; Print[x]; Print[y]; Do[ z = x + y; Print[z, " ", Fibonacci[j + 2]]; x = y; y = z, {j, 1, n}]