Reputation: 15
As the Topic says, module is not callable and I don't really understand why. Its (probably) not the same problem from the similar post, at least I don't know what should I import. I am using SymPy.
And this is a full error text:
Traceback (most recent call last):
File "C:\Users\Marek\Desktop\Bartłomiej\SymPy\PrimeTest.py", line 16, in <module>
if isinstance(evalf((n/p).subs(x, 1)), int):
TypeError: 'module' object is not callable
Full code:
from sympy import *
import math
import sys
import mpmath
sys.modules['sympy.mpmath'] = mpmath
x, y = symbols(' x y ')
#p = sympfy(input(Check this: ))
p = 100
n = expand(((x-1)**p - (x**p - 1)))
print(n)
if isinstance(evalf((n/p).subs(x, 1)), int):
print("This number is a prime!")
else:
print("It is not a prime")
I am trying to make a test for a prime number. (x-1)^p - (x^p - 1), if this is dividable by p and p != 1 then its a prime. My code is not quality because I am changing x to 1 , but I wanna check if it would work..
Upvotes: 0
Views: 1332
Reputation: 308
I think you're using evalf() incorrectly.
From what I've seen, it should be ((n/p).subs(x, 1)).evalf()
https://docs.sympy.org/latest/modules/evalf.html
It might be something else, but give it a try.
Upvotes: 3