mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
complete restructure of the project. minor tweaks
This commit is contained in:
22
mathgenerator/funcs/primeFactorsFunc.py
Normal file
22
mathgenerator/funcs/primeFactorsFunc.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def primeFactorsFunc(minVal=1, maxVal=200):
|
||||
a = random.randint(minVal, maxVal)
|
||||
n = a
|
||||
i = 2
|
||||
factors = []
|
||||
|
||||
while i * i <= n:
|
||||
if n % i:
|
||||
i += 1
|
||||
else:
|
||||
n //= i
|
||||
factors.append(i)
|
||||
|
||||
if n > 1:
|
||||
factors.append(n)
|
||||
|
||||
problem = f"Find prime factors of {a}"
|
||||
solution = f"{factors}"
|
||||
return problem, solution
|
||||
Reference in New Issue
Block a user