This is the submission for the weekly coding challenge.
- The first part of the challenge was to write a single function in python that calculates the 5th, 10th and 100th numbers in the Fibonacci sequence and returns the numbers as outut (together).
- The second part of the challenge was to write a function in python that given a single number A, it returns the numbers in the Fibonacci sequence clsest to A and the two numbers in the Fibonacci sequence immediately smaller and higher than A.
The criteria for the best code are:
- Speed of processing
- Max memory usage
- Coding style
Regarding speed processing and memory usage it is pretty straightforward when knowing code optimization. Therefore, an effort has been put on coding style:
When developing software, it's vital for the programmer to prioritize code readability and user-friendliness. It's essential to remember that the end user might not have any coding expertise. As such, the software should be designed to be as intuitive as possible, without necessitating specialized tools like IDEs or compilers. Incorporating a graphical user interface that provides clear instructions on how to use the software and what inputs are required is crucial. With this perspective in mind, the software has been crafted to offer all essential information, ensuring easy accessibility and optimizing the user experience.
- Create a folder
- Download this code in the created folder.
- Go to your created folder and open the terminal there
- For windows user Hold Shift + Right Click the folder you want it opened on, and click "open command window here".
- For Unix user open the terminal and type
cd myfolder
press enter. Replace the namemyfolder
by the name of the folder you just created.
- Two solution to run the program:
- Drag and drop the program
Fibonacci.py
in the terminal prompt - Run in your terminal
- Drag and drop the program
python Fibonacci.py
- Follow the instruction.
The program will give:
- The average time and its standard deviation to run the specific function (ran 10000 times)
- The maximum memory usage
The output is in this form:
================================================================
ELAPSED TIME:
MEAN:1.2439966201782226e-06 +/- 7.882864856002769e-07 SECONDS
MAX MEMORY USAGE:
/Users/samuel/Desktop/Fibonacci.py:116: size=92 B, count=3, average=31 B
================================================================
The 5 10 and 100th Fibonacci numbers are 5 55 and 354224848179263111168.