Created
March 18, 2015 03:30
-
-
Save good5dog5/e97f2fe6d59149006a80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void fibo_command(int n, char *argv[]) { | |
int i = 0; | |
int first = 0; | |
int second = 1; | |
int result; | |
fio_printf(1, "\r\n"); | |
if(n == 1) { | |
fio_printf(1, "Please assign a number \r\n"); | |
return; | |
} | |
for(i=0; i <= atoi(argv[1]); i++ ) { | |
if( i <= 1) | |
result = i; | |
else | |
{ | |
result = first + second; | |
first = second; | |
second = result; | |
} | |
} | |
fio_printf(1, "The %dth fibonacci number is:%d\r\n",atoi(argv[1]), result); | |
} | |
int atoi(char * str) | |
{ | |
int result = 0; | |
while(*str != 0) | |
{ | |
int c = *str - '0'; | |
result = result * 10 + c; | |
str++; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment