Skip to content

Commit

Permalink
102-fibonacci.c
Browse files Browse the repository at this point in the history
  • Loading branch information
victorpreston committed Jun 20, 2023
1 parent ad6350d commit 460e1aa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Binary file added 0x02-functions_nested_loops/102-fibonacci
Binary file not shown.
31 changes: 31 additions & 0 deletions 0x02-functions_nested_loops/102-fibonacci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdio.h>

/**
* main - prints the first 50 Fibonacci numbers, starting with 1 and 2
* followed by a new line
* Return: Always 0 (Success)
*/
int main(void)
{
long int i, j, k, next;

j = 1;

k = 2;

for (i = 1; i <= 50; ++i)
{
if (j != 20365011074)
{
printf("%ld, ", j);
} else
{
printf("%ld\n", j);
}
next = j + k;
j = k;
k = next;
}

return (0);
}

0 comments on commit 460e1aa

Please sign in to comment.