Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about discrete-mathematics

Read more about discrete-mathematics

python (12.9k questions)

javascript (9.2k questions)

reactjs (4.7k questions)

java (4.2k questions)

java (4.2k questions)

c# (3.5k questions)

c# (3.5k questions)

html (3.3k questions)

Questions - discrete-mathematics

How to handle "((9^x)-2)%5" without overflow at higher x?

I'm doing some exam prep for my discrete mathematics course, and I have to implement the function f(x) = ((9^x)-2)%5 Since the values of our x in the assignment is 100000 < x <= 1000000, I'm hav...
test-img

Thybo

c

discrete-mathematics

integer-overflow

Votes: 0

Answers: 1

Latest Answer

Since you are calculating modulo 5, multiplications can be done modulo 5 as well. 9 is congruent to -1 modulo 5. Thus 9^x is congruent to (-1)^x modulo 5, i.e. 1 if x is even and -1 if x is odd. Subtr...
test-img

nielsen

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved