pascalabcnet/InstallerSamples/SPython/unit_example.pys
Mikhalkovich Stanislav 6d15540895 SPython в 3.11
2025-08-31 17:21:18 +03:00

19 lines
473 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Рекурсивная функция вычисления факториала
def factorial(n: int)-> bigint:
if n == 0:
return 1
return n * factorial(n - 1)
# Не рекурсивная функция вычисления числа Фибоначчи
def fibonacci(n: int)-> bigint:
if n <= 1:
return n
f1: bigint = 0
f2: bigint = 1
for i in range(n - 1):
t = f1 + f2
f1 = f2
f2 = t
return f2