We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b0fd10 commit 4a3e508Copy full SHA for 4a3e508
brain_games/games/brain_gcd_game.py
@@ -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