mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
added iscomposite (#384)
* added iscomposite (Math function) * Update README.md * Update and rename iscomposite.py to is_composite.py Co-authored-by: Luke Weiler <lukew25073@gmail.com>
This commit is contained in:
@@ -112,6 +112,7 @@ This creates the pdf `ws.pdf` in your current directory
|
||||
| 118 | [Percentage difference](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage_difference.py) | What is the percentage difference between 53 and 90? | 51.75% | percentage_difference | `maxValue=200` `minValue=0` |
|
||||
| 119 | [Percentage error](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/percentage_error.py) | Find the percentage error when observed value equals 33 and exact value equals 61. | 45.9% | percentage_error | `maxValue=100` `minValue=-100` |
|
||||
| 120 | [Greatest Common Divisor of N Numbers](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/greatest_common_divisor.py) | GCD(21465961,176654083)= | 1 | greatest_common_divisor | `numbersCount=2` `maximalNumberLimit=10**9` |
|
||||
| 124 | [Is Composite](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/basic_math/is_composite.py) | Is 8 composite? | Yes | is_composite | `maxNum=250`|
|
||||
## calculus
|
||||
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|
||||
|------|-------|-----------------|------------------|---------------|--------|
|
||||
|
||||
25
mathgenerator/funcs/basic_math/is_composite.py
Normal file
25
mathgenerator/funcs/basic_math/is_composite.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
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"])
|
||||
Reference in New Issue
Block a user