Computes Fibonacci and Lucas numbers for a given integer input, supporting decimal, scientific, and hexadecimal formats. Includes optional timing of computation.
Make sure you have GHC (Glasgow Haskell Compiler) installed.
cd fib
ghc fib.hs -o fib
./fib # Linux/macOS
.\fib.exe # Windows
The program supports optional arguments to control output:
--fib
— print only the Fibonacci number--lucas
— print only the Lucas number--print
— print both Fibonacci and Lucas numbersExample run:
./fib --print # Linux/macOS
.\fib.exe --print # Windows
The program will then prompt for a number.
After entering a number, the program prints the requested sequence(s) along with computation time.
Example:
This program computes the Fibonacci and Lucas numbers of a given integer.
Enter a number: 10
F(10) = 55
L(10) = 123
Elapsed time: 0.000001 sec
1e3
), and hexadecimal (e.g., 0xFF
) inputs.This project is licensed under the MIT License.