{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3f8c8d43",
   "metadata": {},
   "source": [
    "# 05-06 · Мини-проект — кратные числа\n",
    "\n",
    "Практика к разделу [«Мини-проект — кратные числа»](../../site/chapters/glava-05/05-06-mini-proekt-itogi.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "990300f5",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Собрать оператор `%` в готовую небольшую программу."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e8056d6",
   "metadata": {},
   "source": [
    "## Рабочий пример"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "79b8395f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:20.091111Z",
     "iopub.status.busy": "2026-08-14T20:52:20.090978Z",
     "iopub.status.idle": "2026-08-14T20:52:20.110010Z",
     "shell.execute_reply": "2026-08-14T20:52:20.109337Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "6\n",
      "9\n",
      "12\n",
      "15\n",
      "18\n",
      "21\n",
      "24\n",
      "27\n",
      "30\n",
      "33\n",
      "36\n",
      "39\n",
      "42\n",
      "45\n",
      "48\n"
     ]
    }
   ],
   "source": [
    "kratnoe_chemu = 3\n",
    "chislo = 1\n",
    "while chislo <= 50:\n",
    "    if chislo % kratnoe_chemu == 0:\n",
    "        print(chislo)\n",
    "    chislo += 1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e35441cc",
   "metadata": {},
   "source": [
    "## Задание ★★ Самостоятельная задача\n",
    "\n",
    "Измените диапазон поиска на 1–100 и кратность — на 7."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "aebbe920",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:20.111084Z",
     "iopub.status.busy": "2026-08-14T20:52:20.110959Z",
     "iopub.status.idle": "2026-08-14T20:52:20.113506Z",
     "shell.execute_reply": "2026-08-14T20:52:20.113117Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7\n",
      "14\n",
      "21\n",
      "28\n",
      "35\n",
      "42\n",
      "49\n",
      "56\n",
      "63\n",
      "70\n",
      "77\n",
      "84\n",
      "91\n",
      "98\n"
     ]
    }
   ],
   "source": [
    "kratnoe_chemu = 7\n",
    "chislo = 1\n",
    "while chislo <= 100:\n",
    "    if chislo % kratnoe_chemu == 0:\n",
    "        print(chislo)\n",
    "    chislo += 1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dfa9e980",
   "metadata": {},
   "source": [
    "## Дополнительная задача ★★★\n",
    "\n",
    "Посчитайте не только сами числа, но и их количество — выведите его в конце."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a18b4e2b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:20.114523Z",
     "iopub.status.busy": "2026-08-14T20:52:20.114414Z",
     "iopub.status.idle": "2026-08-14T20:52:20.116869Z",
     "shell.execute_reply": "2026-08-14T20:52:20.116475Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Найдено чисел: 10\n"
     ]
    }
   ],
   "source": [
    "kratnoe_chemu = 5\n",
    "chislo = 1\n",
    "count = 0\n",
    "while chislo <= 50:\n",
    "    if chislo % kratnoe_chemu == 0:\n",
    "        count += 1\n",
    "    chislo += 1\n",
    "\n",
    "print(\"Найдено чисел:\", count)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9ed5519a",
   "metadata": {},
   "source": [
    "## Проверка результата"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "950688f8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-14T20:52:20.117938Z",
     "iopub.status.busy": "2026-08-14T20:52:20.117808Z",
     "iopub.status.idle": "2026-08-14T20:52:20.120426Z",
     "shell.execute_reply": "2026-08-14T20:52:20.119915Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Верно: от 1 до 50 ровно 10 чисел, кратных 5.\n"
     ]
    }
   ],
   "source": [
    "kratnoe_chemu = 5\n",
    "count = sum(1 for n in range(1, 51) if n % kratnoe_chemu == 0)\n",
    "assert count == 10\n",
    "print(\"Верно: от 1 до 50 ровно 10 чисел, кратных 5.\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
