What do you want to save?
Add Code snippet
New code examples
-
Python 2021-10-06 12:32:03
python recursive fibonacci function
# Python program to display the Fibonacci sequence def recur_fibo(n): if n <= 1: return n else: return(recur_fibo(n-1) + recur_fibo(n-2)) nterms = 10 # check if the number of terms is valid if nterms <= 0: print("Plese... Add solution -
Javascript 2021-10-04 02:59:06
fibonacci sequence javascript
// declare the array starting with the first 2 values of the fibonacci sequence let fibonacci = [0,1]; function listFibonacci(num) { // starting at array index 1, and push current index + previous index to the array for (let i = 1... Add solution -
Python 2021-09-29 00:10:02
fibonacci sequence python code
# WARNING: this program assumes the # fibonacci sequence starts at 1 def fib(num): """return the number at index `num` in the fibonacci sequence""" if num <= 2: return 1 return fib(num - 1) + fib(num - 2) ... Add solution -
Java 2021-09-27 13:59:02
fibonacci java
// WARNING: The function assumes that 'fib(0)=0' and 'fib(1)=1' // Returns the number of the fibonacci sequence at index 'n' public static int fib(int n) { if (n < 2) // No difference if '<' or '<=', because 'fib(2)=2'. return n; return fib(n... Add solution -
Python 2021-09-21 23:13:02
fibonacci list pyton
# WARNING: this program assumes the # fibonacci sequence starts at 1 def fib(num): """return the number at index `num` in the fibonacci sequence""" if num <= 2: return 1 return fib(num - 1) + fib(num - 2) ... Add solution -
Python 2021-09-21 14:17:07
how to do fibonacci sequence in python
# WARNING: this program assumes the # fibonacci sequence starts at 1 def fib(num): """return the number at index `num` in the fibonacci sequence""" if num <= 2: return 1 return fib(num - 1) + fib(num - 2) ... Add solution -
Java 2021-09-08 06:45:04
fibonacci sequence java using recursion
/* Author: Jeffrey Huang This finds the fibonacci number using a term provided by a user A recursive method is used. b) 9 calls are made to the fibonacci sequence in order to compute the 5th term. */ import java.io.*; public class Fibonacci_JeffreyHuang... Add solution -
Python 2021-08-28 04:51:01
fibonacci series print
# Program to display the Fibonacci sequence up to n-th term nterms = int(input("How many terms? ")) # first two terms n1, n2 = 0, 1 count = 0 # check if the number of terms is valid if nterms <= 0: print("Please enter a positive in... Add solution