Skip to content

Commit

Permalink
Update Fibonacci number data types
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWatcher01 committed Apr 3, 2024
1 parent c822de7 commit 0f1b66b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions functions_nested_loops/104-fibonacci.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
int main(void)
{
/* The lower and upper parts of the current and next Fibonacci numbers */
unsigned int a1 = 0, a2 = 1, b1 = 0, b2 = 2, next1, next2, count;
unsigned long int a1 = 0, a2 = 1, b1 = 0, b2 = 2, next1, next2, count;

/* Print the first two Fibonacci numbers */
printf("1, 2");
Expand All @@ -27,11 +27,11 @@ int main(void)

/* Print the next Fibonacci number */
if (next2 > 0)
printf(", %u%09u", next2, next1);
printf(", %lu%09lu", next2, next1);
else
printf(", %u", next1);
printf(", %lu", next1);

/* Update current & next Fibonacci numbers for next loop iteration */
/* Update the current and next Fibonacci numbers for the next loop iteration */
a1 = b1;
a2 = b2;
b1 = next1;
Expand Down

0 comments on commit 0f1b66b

Please sign in to comment.