From 71bccd7fc907bf72a324bdf83f473612e9740f3f Mon Sep 17 00:00:00 2001 From: ArtemPlugnokov <167459091+ArtemPlugnokov@users.noreply.github.com> Date: Wed, 4 Nov 2026 16:37:21 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=80=D1=83=D0=BA=D1=83=D1=80=D1=81=D0=B8?= =?UTF-8?q?=D0=B2=D0=BD=D0=B0=D1=8F=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20factorial()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hello.ipynb | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/hello.ipynb b/hello.ipynb index 273c438..49f17c5 100644 --- a/hello.ipynb +++ b/hello.ipynb @@ -16,7 +16,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 11, + "execution_count": 28, "metadata": { "id": "vpCgcTgTjL3H" }, @@ -48,7 +48,7 @@ "metadata": { "id": "8hUGAyi8jrzi" }, - "execution_count": 23, + "execution_count": 29, "outputs": [] }, { @@ -69,9 +69,9 @@ "base_uri": "https://localhost:8080/" }, "id": "wUcGE8CjjzE-", - "outputId": "2d59d814-9fdf-484b-d908-04cee289f368" + "outputId": "5ce87d69-8cbe-4eef-b5b3-758f4b49eb95" }, - "execution_count": 25, + "execution_count": 30, "outputs": [ { "output_type": "stream", @@ -87,6 +87,46 @@ ] } ] + }, + { + "cell_type": "code", + "source": [ + "def factorial(n: int) -> int:\n", + " \"\"\"Рекурсивный факториал. n >= 0.\"\"\"\n", + " if n < 0:\n", + " raise ValueError(\"factorial не определён для отрицательных чисел\")\n", + " return 1 if n <= 1 else n * factorial(n - 1)" + ], + "metadata": { + "id": "ig6llIpyxFgF" + }, + "execution_count": 31, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "print(f\"5! = {factorial(5)}\")\n", + "print(f\"10! = {factorial(10)}\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "uY-uaNMdxOBF", + "outputId": "238436d9-a806-45eb-e251-360cf52a8ef5" + }, + "execution_count": 32, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "5! = 120\n", + "10! = 3628800\n" + ] + } + ] } ] } \ No newline at end of file