Skip to content
Snippets Groups Projects
recursive.py 627 B
Newer Older
from sys import argv
from contextlib import redirect_stdout

def fatorial(n):
	vfatorial = n*fatorial(n-1)
	return (vfatorial)
 
def bin_coeff(n , k): 
	primeiro = fatorial(i)
	segundo = fatorial(j)
	terceiro = fatorial (i-j)
	return  (primeiro/(segundo*terceiro))

if __name__ == "__main__":
    n = int(argv[1])
    k = int(argv[2])
    with open("triangle.out", "w", encoding="utf-8") as out:
        with redirect_stdout(out):
            for i in range(n+1):
                limit = i+1 if i != n else k+1
                for j in range(limit):
                    print(bin_coeff(i , j), end=" ")
                print()