First time here? Check out the FAQ!

Ask Your Question
0

How to write sage program x congruent to -1 (mod (n-1))

asked 0 years ago

anonymous user

Anonymous

x congruent to -1 (mod (n-1)) is x+1 = k (n-1)

Preview: (hide)

Comments

It's unclear what you want. My best guess is x = Mod(-1, n-1).

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 0 years ago

slelievre gravatar image

Given x and n, let us test whether x is congruent to -1 modulo n - 1.

For this let us write a function.

The test is based on the reformulation provided in the question.

def is_x_congruent_to_minus_one_modulo_n_minus_one(x, n):
    r"""
    Return whether `x` is congruent to `-1` modulo `n - 1`.
    """
    return ZZ(n - 1).divides(ZZ(x + 1))

Use the function as follows:

sage: is_x_congruent_to_minus_one_modulo_n_minus_one(2, 3)
True
sage: is_x_congruent_to_minus_one_modulo_n_minus_one(4, 3)
False
sage: is_x_congruent_to_minus_one_modulo_n_minus_one(5, 3)
True
Preview: (hide)
link

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: 0 years ago

Seen: 45 times

Last updated: May 03