The smallest possible C program to compute Fibonacci numbers

2023/03/27 2:49

Here’s a C program to compute Fibonacci numbers using the fewest number of characters possible:

main(a,b,c){

for(b=c=1;a–;c=a?b+=c:b) ;

printf(“%d”,b) 53}

This program uses a for loop to iterate a number of times specified by theuser input. In each iteration, it calculates the next Fibonacci number by adding the two previous numbers, and stores the result in the “b” variable.

Finally, it prints the last computed number using the printf function.

Note that this program is written in a highly condensed style that sacrifices readability for brevity. In real-world programming, it’s usually better to prioritize clarity and maintainability over minimizing the number of characters.

Back to top