I'm trying to test a function in Jupyter Notebooks that uses gmpy2 to produce prime numbers but I'm getting the following output.
import gmpy2
def solution(i):
n = 2
while True:
yield n
n = str(gmpy2.next_prime(n))
for i in solution(1):
print(i)
input()
2
3
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-14-e0db74781d33> in <module>
6 n = str(gmpy2.next_prime(n))
7
----> 8 for i in solution(1):
9 print(i)
10 input()
<ipython-input-14-e0db74781d33> in solution(i)
4 while True:
5 yield n
----> 6 n = str(gmpy2.next_prime(n))
7
8 for i in solution(1):
TypeError: next_prime() requires 'mpz' argument
Why does the function successfully output the first two numbers in the sequence (2 and 3) but then produce an error? What does mpz
mean?