Skip to content

blovelace84/CodeAlpha_fibonacci_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

This project generates Fibonacci numbers using a generator function. The numbers are displayed one at a time with a delay creating a slow-motion effect. Features:

  1. Uses a generator function to yield Fibonacci numbers infinitely
  2. Implements a time delay between numbers for a smooth display How to run code:
  3. Ensure you have Python installed on your machine
  4. Clone this repository or copy the script
  5. Run the script using the following command on your terminal: python fibonacci_generator.py Code Example: import time

def fibonacci_generator(): a,b = 0, 1 while True: yield a a, b = b, a+b

#Example Usage: fib = fibonacci_generator() for _ in range(20): #Generate the first 20 numbers print(next(fib)) time.sleep(1)

How it works:

  1. The fibonacci_generator() function generates the numbers indefinitely.
  2. the time_sleep(1) function adds a 1-second delay between outputs.
  3. The script prints the first 10 numbers in a slow-motion effect. License: Open source and free to use,

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages