0
#!/home/fury/anaconda3/bin/python
from numba import jit
import sys
@jit(nopython=True)
def isprime(n):
    if n==2:return 1
    if n%2==0:return 0
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:return 0
    return 1
def main():
    print(isprime(float(sys.argv[1])))
if __name__=="__main__":main()

when inputting bigger numbers with more than 22 digits it return wrong value it simply does a modular division wrong for example for the input: 151978145606541879151 >it's saying it is divisible by 13 while its not and it is a perfect prime.

1 Answers1

0

You should not convert input number to float. When you do so, you lose some accuracy. Unfortunately this number exceeds even uint64 size and numba does not support uint128 (https://numba.pydata.org/numba-doc/dev/reference/types.html), so you cannot do it using numba.

maciek97x
  • 2,251
  • 2
  • 10
  • 21