PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''
Filled square matrix algorithm for Python
Coded by Marco Abrate 2017
Challenge by Julian Fechner
Task:
Write a function that gets a positive int n as input and print the filled matrix (n*n) to the screen!
EXAMPLE n = 3:
4 2 1
7 5 3
9 8 6
EXAMPLE n = 4:
7 4 2 1
11 8 5 3
14 12 9 6
16 15 13 10
'''
def summ(num):
if num<=0:
return 0
else:
return num+summ(num-1)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run