Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having a lot of trouble figuring out this discrete math question:

What are the last four bits in the binary expansion of 1234^5555 + 4321 ^5555?

I need to add the two numbers and convert to binary. From what I know so far, to get the last bit from binary, you need to take mod 2. From this, to get the last four bits I understand that you need to take mod 16. However, I don't know how to efficiently take a mod of a very large number or convert a large number to binary.

I've also considered using Fermat's Little Theorem.

Can someone help me out or guide me along the right path?

share|cite|improve this question

$a^m \equiv b^m $ if $a \equiv b$. Thus, $1234^{5555} \equiv 2^{5555}$, which is definitely divisible by 16, so equal to 0 mod 16.

Now, what is 4321 mod 16? What is it when taken to power 5555?

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.