Advertisement
gabbyshimoni

Calculate Fibonachi

Dec 3rd, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. /*
  2.    This program calculate Fibonachi number serie:
  3.    1,1,2,3,5,8,13,21,34...
  4.    each number is the sum of the previous two numbers: 8=5+3, 5=3+2...
  5.  
  6.    Gabby Shimoni, December 2018
  7. */
  8.  
  9. long firstNum = 1;
  10. long secondNum = 1;
  11. long sum;
  12. void setup() {
  13.   Serial.begin(9600);
  14.   sum = firstNum + secondNum;
  15.   Serial.println(firstNum);
  16.   Serial.println(secondNum);
  17.   Serial.println(sum);
  18. }
  19.  
  20. void loop() {
  21.   firstNum = secondNum;
  22.   secondNum = sum;
  23.   sum = firstNum + secondNum;
  24.   Serial.println(sum);
  25.   delay(200);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement