It is my fourth day in a high school robotics class, and we do not have a textbook because the internet.I am going to pick one up soon!
Until then, my homework is to "figure out" how to make this loop of Fibonacci numbers stop after 10 numbers in such a way that he could walk up, know nothing about Fibonacci numbers or anything, and just change the 10 to 20, 25, etc. I thought I could just make it so that while x is greater than 35 to stop, but then he changed the instructions from "just make it stop after 10" to that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int x = 0;
int y = 1;
int fib;
void setup ( )
{
Serial.begin(9600);
Serial.println(x); }
void loop ( )
{
x=y;
y=fib;
fib=x+y;
Serial.println(fib);
delay(500);
}
He also said that if there's a more efficient way to code this, to do so and get the fewest lines of code possible.
Could you describe more about what you're trying to do? I wasn't able to get a clear mental picture from your description.
What is the full assignment?
What do you mean by "stopping after 10"?
Once some of that is cleared up I'll gladly help you along the way!
Excuse me! He said that he wanted it to stop after the first 10 digits of the Fibonacci sequence, and he wanted to easily be able to change the number "10" to a different one to view that many numbers in the Fibonacci sequence.
I will try these suggestions! Thank you very much!