Files
mathgenerator/mathgenerator/funcs/basic_math/is_composite.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

27 lines
620 B
Python

from ...generator import Generator
import random
def gen_func(maxNum=250, format='string'):
a = random.randint(2, maxNum)
problem = f"Is {a} composite?"
if a == 0 or a == 1:
solution = "No"
return (problem, solution)
for i in range(2, a):
if a % i == 0:
solution = "Yes"
return (problem, solution)
solution = "No"
if format == 'string':
return problem, solution
elif format == 'latex':
return "Latex unavailable"
else:
return a, solution
is_composite = Generator('Is Composite', 124, gen_func, ["maxNum=250"])