/* * Program to Display Fibonacci Sequence - Fibonacci Sequence Up to a Certain Number */ #include /* Entry point to program */ int main() { unsigned long t1 = 0, t2 = 1, nextTerm = 0, n; printf("Enter a positive number (max. 2147483647): "); scanf("%ld", &n); /* scanf isn't able process unsigned long */ printf("Maximum: %lu \n", n); /* Displays the first two terms which is always 0 and 1 */ printf("Fibonacci Series: %lu, %lu, ", t1, t2); nextTerm = t1 + t2; while (nextTerm < n) { printf("%lu, ", nextTerm); nextTerm = t1 + t2; t1 = t2; t2 = nextTerm; } return 0; }