Files
mathgenerator/mathgenerator/funcs/misc/common_factors.py
Luke Weiler 8e264e6b23 Remove mathgen (#396)
* Improve generator __init__ function

* Move Generator to new file, remove mathgen

* Remove getGenList redundancies

* Add backwards compatibility import mathgen from

* Insort to genList

* Linter fixes

* Lint fixes
2022-12-19 14:01:52 -05:00

35 lines
748 B
Python

from ...generator import Generator
import random
def gen_func(maxVal=100, format='string'):
a = x = random.randint(1, maxVal)
b = y = random.randint(1, maxVal)
if (x < y):
min = x
else:
min = y
count = 0
arr = []
for i in range(1, min + 1):
if (x % i == 0):
if (y % i == 0):
count = count + 1
arr.append(i)
if format == 'string':
problem = f"Common Factors of {a} and {b} = "
solution = arr
return problem, solution
elif format == 'latex':
return "Latex unavailable"
else:
return a, b, arr
common_factors = Generator("Common Factors", 40, gen_func,
["maxVal=100"])