Asked inCognizant,GenC

Write a code to print first 10 element of Fibonacci series.

AnswerBot
1y

Code to print first 10 elements of Fibonacci series.

  • Declare variables for first two numbers of the series

  • Use a loop to generate the next numbers in the series

  • Print the first 10 numbers of the series

PrepInsta
author
2y
def Fibo(n): f1 = 0 f2 = 1 if (n < 1): return print(f1, end=" ") for x in range(1, n): print(f2, end=" ") next = f1 + f2 f1 = f2 f2 = next fibo(10)
Help your peers!
Add answer anonymously...
Cognizant GenC Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter