Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python program to find the sum of fibonacci series

# Python 3 Program to find
# sum of Fibonacci numbers
 
 
# Computes value of first
# fibonacci numbers
def calculateSum(n) :
    if (n <= 0) :
        return 0
  
    fibo =[0] * (n+1)
    fibo[1] = 1
  
    # Initialize result
    sm = fibo[0] + fibo[1]
  
    # Add remaining terms
    for i in range(2,n+1) :
        fibo[i] = fibo[i-1] + fibo[i-2]
        sm = sm + fibo[i]
         
    return sm
 
 
# Driver program to test
# above function
n = 4
print("Sum of Fibonacci numbers is : " ,
      calculateSum(n))
 
Comment

PREVIOUS NEXT
Code Example
Python :: generate n different colors matplotlib 
Python :: self in python 
Python :: streamlit sidebar width 
Python :: file open in python 
Python :: keras model save 
Python :: get char from ascii value python 
Python :: Username Promt using Python with Character Limit 
Python :: models in django 
Python :: class indexing 
Python :: numpy array deepcopy 
Python :: download images off unsplash python 
Python :: python how to insert values into string 
Python :: initialize np array 
Python :: pytorch check if tensor is on gpu 
Python :: netcdf in python 
Python :: install scrapy on pycharm 
Python :: python working with files and dirs 
Python :: pca 
Python :: oops concept in python 
Python :: missing data in python 
Python :: Display an image over another image at a particular co-ordinates in openCV 
Python :: django cleanup 
Python :: calculate quantiles python 
Python :: argparse accept only few options 
Python :: pandas dataframe row names 
Python :: loads function in json python 
Python :: code 
Python :: python string to operator 
Python :: numpy evenly spaced numbers 
Python :: python check if input contains letters 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =