recursion

command
v0.0.0-...-cf25b83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 2 Imported by: 0

README

recursion example

A function calling itself to make a fibonacci series.

GitHub Webpage

FIBONACCI SERIES

Each Fibonacci number is the sum of the two preceding numbers.

Hence, the simplest series is 1, 1, 2, 3, 5, 8, etc...

METHOD 1

For this example given n, complete the fibonacci function so it returns fibonacci(n) where,

fibN := fibonacci(n - 2) + fibonacci(n - 1)

The problem is the it always calculates backwards and does the same thing over and over. There is a lot of processing here.

METHOD 2

This is more of a bottom up approach that I like better. It more flows what I would do with a pen and piece of paper.

RUN

go run recursion1.go
go run recursion2.go

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL