stephen reidy
/
lab2_fib_complete
Fib , lab2 complete
Diff: main.cpp
- Revision:
- 0:f20f7680069b
diff -r 000000000000 -r f20f7680069b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Apr 28 09:47:02 2021 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" // Stephen Reidy; lab2 + +int j=1, k=0, fib=0; // Integers initialised +int N = 10; // Integers initialised + +int fibb(int inp) +{ + if (inp == 0) // if statemant to return 0 + return 0; + else if (inp == 1) // else if statemant to return 1 + return 1; + else // else to return fibb calculation + return (fibb(inp -1) + (inp -2)); +} + +int main() //Main structure +{ + for (int i=0; i<10; i++) //for loop, including conditions + printf("%d, ", fibb(i)); //fibb printout (i), PC (Tera term) + printf("\r\n"); +}