Ask Your Question
0

Error in Sage? Integer object is not callable

asked 2024-04-08 00:16:53 +0100

Andr gravatar image

I call

p = random_prime(5000000, True, 4000000)
print(factor(p-1))

by copy from text file to sage terminal is OK next, I run

factors = [2]

def find_generator(p):
    return 1

for factor in factors:
    generator = find_generator(factor)

no errors yet but when I repeat

p = random_prime(5000000, True, 4000000)
print(factor(p-1))

Is error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-458583a9b4df> in <module>
      1 p = random_prime(Integer(5000000), True, Integer(4000000))
----> 2 print(factor(p-Integer(1)))

TypeError: 'sage.rings.integer.Integer' object is not callable

How avoid this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2024-04-08 04:49:27 +0100

Max Alekseyev gravatar image

updated 2024-04-08 13:36:21 +0100

Your loop for factor in factors: assigns an integer value to factor object. So, you cannot call factor(p-1) afterwards.

A simple fix is to give the loop variable another name - e.g. for myfactor in factors:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-04-08 00:16:53 +0100

Seen: 208 times

Last updated: Apr 08