Skip to content

Commit 7d7c597

Browse files
committed
Preparazione per il nuovo anno accademico
1 parent 90a20f5 commit 7d7c597

File tree

117 files changed

+24
-531422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+24
-531422
lines changed

Fibonacci.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Wed Oct 11 23:13:50 2017
4+
5+
@author: gualandi
6+
"""
7+
8+
# Processo con ricorsione ad albero
9+
def Fib(n):
10+
if n == 0:
11+
return 0
12+
if n == 1:
13+
return 1
14+
return Fib(n-1) + Fib(n-2)
15+
16+
# Processo iterativo lineare
17+
def FibIter(a, b, count):
18+
if count == 0:
19+
return b
20+
else:
21+
return FibIter(a+b, a, count-1)
22+
23+
def FibI(n):
24+
return FibIter(1, 0, n)

0 commit comments

Comments
 (0)