Esempio n. 1
0
def test_isPrime():
    assert mymath.isPrime(-1) == False, "-1 Prime Undefined"
    assert mymath.isPrime(0) == True, "0 is Prime"
    assert mymath.isPrime(1) == True, "1 is Prime"
    assert mymath.isPrime(2) == True, "2 is Prime"
    assert mymath.isPrime(3) == True, "3 is Prime"
    assert mymath.isPrime(5) == True, "5 is Prime"
    assert mymath.isPrime(6) == False, "6 is not Prime"
    assert mymath.isPrime(20) == False, "20 is not Prime"
    assert mymath.isPrime(23) == True, "23 is Prime"
Esempio n. 2
0
def getPrimes(foo):
  i=1
  primes=[]
  while i < foo:
    if mymath.isPrime(i):
      #print i
      primes.append(i)
    i = i + 1
  return primes
Esempio n. 3
0
 def test_isPrime(self):
     result = mymath.isPrime(-1)
     self.assertFalse(result)
     result = mymath.isPrime(0)
     self.assertTrue(result)
     result = mymath.isPrime(1)
     self.assertTrue(result)
     result = mymath.isPrime(2)
     self.assertTrue(result)
     result = mymath.isPrime(3)
     self.assertTrue(result)
     result = mymath.isPrime(5)
     self.assertTrue(result)
     result = mymath.isPrime(6)
     self.assertFalse(result)
     result = mymath.isPrime(20)
     self.assertFalse(result)
     result = mymath.isPrime(23)
     self.assertTrue(result)
Esempio n. 4
0
import mymath

input1=13195
primes=[]

i=0
while i < input1:
  if mymath.isPrime(i):
    primes.append(i)
  i = i + 1

print primes
Esempio n. 5
0
x = int(input("Enter 1st number: "))
y = int(input("Enter 2nd number: "))
print()

# Call the add function
resAdd = mymath.add(x, y)
print("Sum =", resAdd)

#Call the subtract function
resSub = mymath.subtract(x, y)
print("Difference =", resSub)

#Call the multiply function
resMul = mymath.multiply(x, y)
print("Product =", resMul)

#Call the divide function
resDiv = mymath.divide(x, y)
print("Division =", resDiv)
print()

#Call the isPrime function
resPri = mymath.isPrime(x)
if resPri == True:
    print(x, "is Prime")
else:
    print(x, "is not Prime")

#Call the factorial function
resFac = mymath.factorial(y)
print(y, "Factorial =", resFac)