Skip to content

Instantly share code, notes, and snippets.

@jeremy5189
Last active December 25, 2015 14:39
Show Gist options
  • Save jeremy5189/6992170 to your computer and use it in GitHub Desktop.
Save jeremy5189/6992170 to your computer and use it in GitHub Desktop.
/*
* Fibonacci Sequence Application
* http://oj.sslab.cs.nthu.edu.tw/problems/12
* Authored by Jeremy Yen 2013.10.15
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
// Fibonacci & Sequence Storing
int a[500];
// For Variable
int i, j;
// Counting Sequence
int count = 1;
// Input
int input;
scanf("%d", &input);
// Initialize
a[0] = 1;
a[1] = 1;
int n = 1;
for( i = 0; i < input; i++ )
{
int tmp = 1;
if( i != 0 && i != 1) {
a[i] = a[i-1] + a[i-2];
tmp = a[i];
}
int stop = 0;
for( j = 0; j < tmp; j++ )
{
if( count == input ) {
printf("%d\n",n);
stop = 1;
break;
}
count++;
}
if(stop)
break;
n++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment