Created
May 27, 2014 03:23
-
-
Save jsfaint/712d4882417978cd50fd 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
#include <cstdio> | |
const int max = 65000; | |
const int lineLength = 12; | |
void fibonacci( int max ) | |
{ | |
if ( max < 2 ) | |
return; | |
printf("0 1 "); | |
int v1 = 0, v2 = 1, cur; | |
for ( int ix = 3; ix <= max; ++ix ) { | |
cur = v1 + v2; | |
if ( cur > ::max ) break; | |
printf("%d ", cur); | |
v1 = v2; | |
v2 = cur; | |
if (ix % lineLength == 0) | |
puts(""); | |
} | |
} | |
void fibonacci( int ); | |
int main() | |
{ | |
printf("Fibonacci Series: 20\n"); | |
fibonacci(20); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment