Checking-For-Fibonacci-Syquence-In-Python - Checking For Fibonacci Syquence In Python

Overview

Checking-For-Fibonacci-Syquence-In-Python

The Fibonacci sequence is a set of numbers that starts with a one or a zero, followed by a one, and proceeds based on the rule that each number (called a Fibonacci number) is equal to the sum of the preceding two numbers.

The purpose of this Python script is to check if an entered number is part of the Fibonnacci Sequence or Not

The Fibonacci Sequence (1,1,2,3,5,8,13,21,34,55,89,144,233,377...... is derived as below

1+1=2 #...... 13+21=34

1+2=3 #...... 21+34=55

2+3=5 #...... 34+55=89

3+5=8 #...... 55+89=144

5+8=13 #...... 89+144=233

8+13=21 #...... 144+233=377

Declaring the function

def CheckForFibonacci(): # Next, asking user to define their target number to check numberToCheck = int(input("Enter Number: "))

Notably, in the Fibonacci Sequence, the first three terms contains only 0 and 1

This originates from the fact that the next value, is the sum of its two predecesors

Thus, the first three values of the Fibonacci Sequence are 0, 1, 1

numZero = 0
numOne = 1
numTwo = 1

Part 1: Doing the first/initial check immediately the user enters a value based on 0 & 1

if (numberToCheck == 0 or numberToCheck == 1):
    print("The Number is a part of Fibonacci Sequence")

Part 2: For values greater than 0 and 1

else:
    while numZero < numberToCheck:
        numZero = numOne + numTwo
        numTwo = numOne
        numOne = numZero
    if numZero == numberToCheck:
        print("The Number is part of Fibonacci Sequence")
    else:
        print("NO!, Number NOT part of Fibonacci Sequence")

Call the function

CheckForFibonacci()

Other External Resources To find out more on creating the Fibonacci Sequence, please visit https://www.programiz.com/python-programming/examples/fibonacci-sequence and https://factpros.com/fibonacci-sequence-facts/

You might also like...
Python with braces. Because Python is awesome, but whitespace is awful.

Bython Python with braces. Because Python is awesome, but whitespace is awful. Bython is a Python preprosessor which translates curly brackets into in

PSP (Python Starter Package) is meant for those who want to start coding in python but are new to the coding scene.

Python Starter Package PSP (Python Starter Package) is meant for those who want to start coding in python, but are new to the coding scene. We include

Py-Parser est un parser de code python en python encore en plien dévlopement.

PY - PARSER Py-Parser est un parser de code python en python encore en plien dévlopement. Une fois achevé, il servira a de nombreux projets comme glad

Simple, high-school-leveled sequence library written in Python / 간단한 고등학교 수준 수열 라이브러리 (Python)
A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz

A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz has some issues building with python 3.10

A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning  Essence.
A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

Run python scripts and pass data between multiple python and node processes using this npm module

Run python scripts and pass data between multiple python and node processes using this npm module. process-communication has a event based architecture for interacting with python data and errors inside nodejs.

inverted pendulum fuzzy control python code (python 2.7.18)
inverted pendulum fuzzy control python code (python 2.7.18)

inverted-pendulum-fuzzy-control- inverted pendulum fuzzy control python code (python 2.7.18) We have 3 general functions for 3 main steps: fuzzificati

Izy - Python functions and classes that make python even easier than it is

izy Python functions and classes that make it even easier! You will wonder why t

Owner
John Michael Oliba
 John Michael Oliba
This is a simple python script for checking A/L Examination results of srilankan students

AL-Result-Checker This is a simple python script for checking A/L Examination results of srilankan students INSTALLATION [Termux] [Linux] : apt-get up

Razor Kenway 8 Oct 24, 2022
A tool for checking if the external data used in Flatpak manifests is still up to date

Flatpak External Data Checker This is a tool for checking for outdated or broken links of external data in Flatpak manifests. Motivation Flatpak apps

Flathub 76 Dec 24, 2022
An integrated library for checking email if it is registered on social media

An integrated library for checking email if it is registered on social media

Sidra ELEzz 13 Dec 8, 2022
A module to prevent invites and joins to Matrix rooms by checking the involved server(s)' domain.

Synapse Domain Rule Checker A module to prevent invites and joins to Matrix rooms by checking the involved server(s)' domain. Installation From the vi

matrix.org 4 Oct 24, 2022
Similarity checking of sign languages

Similarity checking of sign languages This repository checks for similarity betw

Tonni Das Jui 1 May 13, 2022
Todos os exercícios do Curso de Python, do canal Curso em Vídeo, resolvidos em Python, Javascript, Java, C++, C# e mais...

Exercícios - CeV Oferecido por Linguagens utilizadas atualmente O que vai encontrar aqui? ?? Esse repositório é dedicado a armazenar todos os enunciad

Coding in Community 43 Nov 10, 2022
PyDy, short for Python Dynamics, is a tool kit written in the Python

PyDy, short for Python Dynamics, is a tool kit written in the Python programming language that utilizes an array of scientific programs to enable the study of multibody dynamics. The goal is to have a modular framework and eventually a physics abstraction layer which utilizes a variety of backends that can provide the user with their desired workflow

PyDy 307 Jan 1, 2023
A Python script made for the Python Discord Pixels event.

Python Discord Pixels A Python script made for the Python Discord Pixels event. Usage Create an image.png RGBA image with your pattern. Transparent pi

Stanisław Jelnicki 4 Mar 23, 2022
this is a basic python project that I made using python

this is a basic python project that I made using python. This project is only for practice because my python skills are still newbie.

Elvira Firmansyah 2 Dec 14, 2022
Analisador de strings feito em Python // String parser made in Python

Este é um analisador feito em Python, neste programa, estou estudando funções e a sua junção com "if's" e dados colocados pelo usuário. Neste código,

Dev Nasser 1 Nov 3, 2021