Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

James White and Don Kelly Fibonacci Solution #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion js/fibonacci.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
const fibonacci = (num) => {

var prior = 0
var current = 1
if (num <= 1) {
return num
}
for (i = 2; i <= num; i++) {
next = prior + current
prior = current
current = next
}
return current
}

module.exports = {fibonacci}
Binary file added python/__pycache__/fibonacci.cpython-39.pyc
Binary file not shown.
15 changes: 13 additions & 2 deletions python/fibonacci.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
def fibonacci(n):
pass
def fibonacci(num):
past = 0
current = 1
if num <= 1:
return num
for num in range(num - 1):
next = current + past
past = current
current = next
return current

fibonacci(8)