Skip to content

Commit 400e4fd

Browse files
committed
aggiunta quinta lezione (solo funzioni)
1 parent aa64483 commit 400e4fd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

quinta-lezione/funzioni.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def fattoriale(n):
2+
if n>1:
3+
return n*fattoriale(n-1)
4+
else:
5+
return 1
6+
7+
def max_factor_greater_than(n, d):
8+
if (n%d==0):
9+
return d
10+
else:
11+
return max_factor_greater_than(n, d+1)
12+
13+
def prime(n):
14+
return max_factor_greater_than(n,2)==n
15+
16+
def mcd(a, b):
17+
if a==b:
18+
return a
19+
if a>b:
20+
return mcd(a, a-b)
21+
22+

0 commit comments

Comments
 (0)