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:
Hussain Omer
2022-08-17 22:51:36 -04:00
committed by GitHub
parent 712c74fbe3
commit 36777d685f
2 changed files with 26 additions and 0 deletions

View File

@@ -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` | | 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` | | 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` | | 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 ## calculus
| Id | Skill | Example problem | Example Solution | Function Name | Kwargs | | Id | Skill | Example problem | Example Solution | Function Name | Kwargs |
|------|-------|-----------------|------------------|---------------|--------| |------|-------|-----------------|------------------|---------------|--------|

View 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"])