Skip to content

Instantly share code, notes, and snippets.

@good5dog5
Created March 18, 2015 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save good5dog5/e97f2fe6d59149006a80 to your computer and use it in GitHub Desktop.
Save good5dog5/e97f2fe6d59149006a80 to your computer and use it in GitHub Desktop.
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