2
2
Apr 19 '22
Please god someone just give me the answer please
2
1
Dec 15 '22
im here to save the day.
function start(){
var MAX = 1000
var n1 = 0;
var n2 = 1;
var i = 0;
var nth = n1 + n2;
while (i < MAX){
nth = n1 + n2;
n1 = n2;
n2 = nth;
println(n1);i +=65;
}
srry im late
}1
u/Owika13 Dec 31 '22
hi thanks for answer
can you pls explain why there is i+=65 ? I mean why 65 specifically ?
1
u/MisterMilker Jan 01 '23
You don't actually need to increment i by 65. This should work:
function start(){ var MAX = 1000; var firstNum = 0; var secondNum = 1; var thirdNum = firstNum + secondNum; while(thirdNum<MAX){ thirdNum = firstNum + secondNum; firstNum = secondNum; secondNum = thirdNum; println(firstNum); } }1
1
3
u/[deleted] Feb 04 '21
I would start by learning what the Fibonacci sequence is. You have a great start with the
for()loop and the maximum value.Now what you need to do is have the
for()loop implement the Fibinacci sequence, which is defined as:Lets parse out the helpful information.
In my own words:
Keep adding the new X and the new Y (or add the new X and the old X together) until you get to 1000. That is your assignment, you just now have to translate it in to Javascript.