ONLINE SUMMER TRAINING Online Courses Free Tutorials 
 Placement Preparation 
Artificial Intelligence(AI) & Machine Learning(ML) Training in Jaipur
0 like 0 dislike
176 views
in RTU/BTU B.Tech(CSE-VI SEM) PYTHON LAB by Goeduhub's Expert (7.6k points)
By considering the terms in Fabonacci seq. whose value does not exceed 4 mil. WAP to find the sum of even valued terms

Goeduhub's Online Courses @Udemy

For Indian Students- INR 570/- || For International Students- $12.99/-

S.No.

Course Name

Apply Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Computer Vision with OpenCV | Deep Learning CNN Projects

Apply Coupon

3.

Complete Machine Learning & Data Science with Python Apply Coupon

4.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

5.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon

6.

Complete Python Programming from scratch with Projects Apply Coupon

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.6k points)
edited by
 
Best answer

Ques. By considering the terms in Fabonacci seq. whose value does not exceed 4 mil. WAP to find the sum of even valued terms

Answer : Here i have just given a example upto 50=n you can take 4,000,000

Program : 

def fib(n):

    a=0

    b=1

    a1=[]

    a1.append(a)

    a1.append(b)

    s=0

    for i in range(1,n+1):

        c=a+b

        a1.append(c)

        a=b

        b=c

    print(a1)

    for j in a1:

        if j%2==0:

            s=s+j

    print("sum of even terms upto",n,"are : ",s)

fib(50)

Output : 

[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025, 20365011074]

sum of even terms upto 50 are :  26658145586


For more Rajasthan Technical University CSE VI Sem Python Lab Experiments Click here

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

Related questions

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...