Beispiel #1
0
def givePrimeAt(index=100001):  #// my first simple algorithm
    if (index < 1 or isinstance(index, float)):
        return -1
    if index == 1:
        return 2
    prime_numbers = [2, 3]
    i = 1
    while len(prime_numbers) < index:
        prime_number = giveNextPrimeAt(i)
        isPrime(prime_number) and prime_numbers.append(prime_number)
        i += 1
    return prime_numbers[index - 1]
Beispiel #2
0
 def test_giveNextPrimeAt_should_return_35_for_11_which_is_wrong_but_this_method_is_supposed_to_give_prime_candidates_also(
         self):
     self.assertEquals(giveNextPrimeAt(11), 35)
     self.assertEquals(giveNextPrimeAt(8), 25)
Beispiel #3
0
 def test_giveNextPrimeAt_should_return_1_for_0(self):
     self.assertEquals(giveNextPrimeAt(0), 1)
Beispiel #4
0
 def test_giveNextPrimeAt_should_return_minus_1_for_minus_1(self):
     self.assertEquals(giveNextPrimeAt(-1), -1)
     self.assertEquals(giveNextPrimeAt(-8), -23)
Beispiel #5
0
 def test_giveNextPrimeAt_should_return_5_for_1_and_7_for_2(self):
     self.assertEquals(giveNextPrimeAt(1), 5)
     self.assertEquals(giveNextPrimeAt(2), 7)