mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
24 lines
581 B
Python
24 lines
581 B
Python
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
def isprime(max_a=100):
|
|
a = random.randint(2, max_a)
|
|
problem = a
|
|
if a == 2:
|
|
solution = True
|
|
return (problem, solution)
|
|
if a % 2 == 0:
|
|
solution = False
|
|
return (problem, solution)
|
|
for i in range(3, a // 2 + 1, 2):
|
|
if a % i == 0:
|
|
solution = False
|
|
return (problem, solution)
|
|
solution = True
|
|
return (problem, solution)
|
|
|
|
|
|
is_prime = Generator('isprime', 74, 'a any positive integer',
|
|
'True/False', isprime)
|