Below you will find pages that utilize the taxonomy term “raspberry pi”
February 24, 2024
Generating the Fibonacci sequence on a Raspberry Pi 5
Linux includes a bench calculator called bc, which can achieve remarkable arbitrary-precision results in very few lines of code. For ease of running, code can be embedded in a here document:
fib.sh
#!/usr/bin/env bash BC_LINE_LENGTH=0 bc -q <<end 0;1; for (i=1;i<1000;i++) {g=last;last+=f;f=g;last} end The BC_LINE_LENGTH environment variable is used to prevent long lines from being split with a \ continuation character.
The -q flag suppresses the welcome prompt.
The 0;1; bit just prints the first two results.
read more