From c7bf10ba29be9fb8be7ef17f04ac0473cd40b022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B0=D1=82=D1=8C=D1=8F=D0=BD=D0=B0=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B4=D1=80=D0=B5=D0=B5=D0=B2=D0=B0?= Date: Fri, 13 Oct 2023 14:21:08 +0300 Subject: [PATCH] a --- README.md | 1 + bin/brain-gcd.js | 2 +- games/gcd.js | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 bin/brain-gcd.js diff --git a/README.md b/README.md index 7c4e455..84b6323 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,4 @@ [![Actions Status](https://github.com/Tanya14081981/frontend-project-44/workflows/hexlet-check/badge.svg)](https://github.com/Tanya14081981/frontend-project-44/actions)[![Maintainability](https://api.codeclimate.com/v1/badges/fb74f85f99b4a3def279/maintainability)](https://codeclimate.com/github/Tanya14081981/frontend-project-44/maintainability) [![asciicast](https://asciinema.org/a/zvjF8kuKtS1kQq1tsTn6nrJ9X.svg)](https://asciinema.org/a/zvjF8kuKtS1kQq1tsTn6nrJ9X) [![asciicast](https://asciinema.org/a/80aEm0j9jSN4PvcgJ6dGstUcG.svg)](https://asciinema.org/a/80aEm0j9jSN4PvcgJ6dGstUcG) +[![asciicast](https://asciinema.org/a/AslmjHGvRdJ3wVy362nPGGLUV.svg)](https://asciinema.org/a/AslmjHGvRdJ3wVy362nPGGLUV) diff --git a/bin/brain-gcd.js b/bin/brain-gcd.js old mode 100644 new mode 100755 index 602e09f..d67f11e --- a/bin/brain-gcd.js +++ b/bin/brain-gcd.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -import maxGeneralDivider from '../games/calc.js'; +import maxGeneralDivider from '../games/gcd.js'; maxGeneralDivider(); diff --git a/games/gcd.js b/games/gcd.js index 4299831..bef4a6d 100644 --- a/games/gcd.js +++ b/games/gcd.js @@ -5,10 +5,11 @@ import greetGamer from '../src/cli.js'; import getRandomInt from '../function/getRandomInt.js'; const getMaxDevidor = (numberOne, numberTwo) => { - let maxDevidor = 0; + const maxNum = Math.max(numberOne, numberTwo); + let maxDevidor = 1; let value1 = numberOne; let value2 = numberTwo; - for (let i = 1; i <= numberOne; i += 1) { + for (let i = 1; i <= maxNum; i += 1) { if (value1 === value2) { maxDevidor = value1; } else if (value1 > value2) {