Skip to content

Commit 5a9564a

Browse files
author
Виталий
committed
Fix prime.py and gcd.py and README.md
1 parent f27d723 commit 5a9564a

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
### Hexlet tests and linter status:
22
[![Actions Status](https://github.com/Vitaliy-Berezhnoy/python-project-49/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/Vitaliy-Berezhnoy/python-project-49/actions)
33
<a href="https://codeclimate.com/github/Vitaliy-Berezhnoy/python-project-49/maintainability"><img src="https://api.codeclimate.com/v1/badges/3e3c695d3a98ff59c1d0/maintainability" /></a>
4-
<a href="https://asciinema.org/a/9Skt2FbW7LSCkBky9LgDa7NLe" target="_blank"><img src="https://asciinema.org/a/9Skt2FbW7LSCkBky9LgDa7NLe.svg" /></a>
5-
64

75
**Demonstration of different outcomes of games.**
86

brain_games/games/gcd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from random import randint
22

33

4-
def nod(a, b): # нахождение наибольшего общего делителя
5-
while a != 0 and b != 0:
6-
if a > b:
7-
a = a % b
4+
def nod(num1, num2): # нахождение наибольшего общего делителя
5+
while num1 != 0 and num2 != 0:
6+
if num1 > num2:
7+
num1 = num1 % num2
88
else:
9-
b = b % a
10-
return (a + b)
9+
num2 = num2 % num1
10+
return (num1 + num2)
1111

1212

1313
rules = "Find the greatest common divisor of given numbers."

brain_games/games/prime.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
from random import randint
22

3+
4+
# функция проверяет является ли число простым
5+
# если число простое -> False
6+
# если нет -> True
7+
def is_prime(number):
8+
if number <= 1:
9+
return False
10+
if number == 2:
11+
return True
12+
if number % 2 == 0:
13+
return False
14+
for i in range(3, int(number**0.5) + 1, 2):
15+
if number % i == 0:
16+
return False
17+
return True
18+
19+
320
rules = '"yes" if given number is prime. Otherwise answer "no".'
421
questions = []
522
right_answer = []
6-
prime_numbers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
723
for _ in range(3):
8-
number = randint(2, 31)
24+
number = randint(1, 100)
925
questions.append(number)
10-
if number in prime_numbers:
26+
if is_prime(number):
1127
right_answer.append('yes')
1228
else:
1329
right_answer.append('no')

0 commit comments

Comments
 (0)