Clarification on Project Euler Problems...

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
User avatar
kenbrooker
Posts: 187
Joined: Mon Feb 19, 2018 3:05 am
Location: Northern California, USA

Clarification on Project Euler Problems...

Post by kenbrooker »

ok... I give up... Why are so many Project Euler problem solutions
qualified as mod (10^9 + 7 [or + 9])??
"Good Judgment comes from Experience;
Experience comes from Bad Judgment
..."
Image
philiplu
Posts: 92
Joined: Wed Aug 02, 2017 8:51 pm
Location: Redmond, WA, USA

Re: Clarification on Project Euler Problems...

Post by philiplu »

They're both prime, so certain useful theorems in modular arithmetic which require either a prime or coprime modulus will work (intentionally not saying what those are - plenty of problems revolve around discovering those). Also, they're below $2^{30}$, so if you compute $a*b \pmod{1000000007}$, where $a$ and $b$ are both below the modulus, the intermediate result of the multiplication will stay below $2^{63}$ so you don't hit overflow issues when using signed or unsigned 64-bit integers. Seems like lots of problems are sized to stay within 64-bit arithmetic limits, so they're easier to handle in languages like C++ without automatic infinite-precision integers. If, say, Python, is your language of choice, that's not an issue, other than the slowdown you'll hit if your ints exceed 64 bits.
Image
User avatar
kenbrooker
Posts: 187
Joined: Mon Feb 19, 2018 3:05 am
Location: Northern California, USA

Re: Clarification on Project Euler Problems...

Post by kenbrooker »

ThankYouSIR!
"Good Judgment comes from Experience;
Experience comes from Bad Judgment
..."
Image
Post Reply