Skip to content

Commit 4a3e508

Browse files
committed
код игры brain_gcd
1 parent 8b0fd10 commit 4a3e508

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from random import randrange
2+
3+
from brain_games.engine import engine_game
4+
5+
rules = 'Find the greatest common divisor of given numbers.'
6+
7+
8+
def get_question_answer():
9+
n1 = randrange(1, 51)
10+
n2 = randrange(1, 51)
11+
question = f'{n1} {n2}'
12+
13+
a = min(n1, n2)
14+
res = []
15+
for i in range(1, a + 1):
16+
if n1 % i == 0 and n2 % i == 0:
17+
res.append(i)
18+
correct_answer = max(res)
19+
return question, correct_answer
20+
21+
22+
def brain_gcd():
23+
engine_game(rules, get_question_answer)

0 commit comments

Comments
 (0)