Possible Duplicate:
How do I adapt to pre-interview challenge questions?

InterviewStreet is a new company that essentially acts as a filter for companies to find programmers that can code. My problem is my math is fairly weak and I'd like to study it, even if it's from the ground up, to be able to solve questions such as this one, that is found on their site:

Find the no of positive integral solutions for the equations (1/x) + (1/y) = 1/N! (read 1 by n factorial) Print a single integer which is the no of positive integral solutions modulo 1000007

Now, please do NOT post the answer to that question, it is taken directly from InterviewStreet and should not be posted here. It is not the answer I'm seeking for in this thread. What I'm asking is a more fundamental question which probably can be answered by some of the hackers in the SO community.

How does one prepare for such a question? What resources are available for me to study/learn how to solve this type of problem? Is this covered on MIT open courseware? Khan Academy? Any particular books? I'm not even sure where to begin to start solving the problem above and I'd like to learn what steps I can take to do so.

  • don't get me wrong - I like this kinds of question a lot (little puzzles for the weekend) - but I really don't think you will find good programmes with those - you will find math-geeks (that might be good at programmig) - and we all know that those people get code done, but the person next to them will never be able to read their code :) ... want to know if someone is any good? Sit down and to 2hr pair programming with that person and you will learn a lot more than if he happens to like Gardner-puzzles
    – Random Dev
    Aug 31, 2011 at 22:04

3 Answers 3


Often interview questions are designed to test your problem-solving skills without needing any specialist knowledge. But for your question, some mathematical knowledge would definitely help. At the very least, you'll need to understand the definitions of 'positive integral' and 'modulo'. An introductory course in number theory might be useful, perhaps this one from OCW.

I'd also recommend Project Euler for sample problems - it's a great way of developing your mathematical and programming knowledge. Pick a language and start working through the exercises.


You can't prepare for these kinds of problems by simply memorizing a book. The only way to be good at problem solving is by doing lots and lots of problems. I do suggest getting an algorithms and data structures book and reading through it though. It'll significantly speed up the process.

I remember a few years back I spent an entire summer (5+ hours a day) practicing solving these types of problems just for fun.

There are a number of places where you can do this. Project Euler is a good starting point. UVa Online Judge also has tons of problems.

  • That's some commitment. Did you find it helped you in your general programming ability? Aug 8, 2011 at 18:22
  • 3
    Absolutely. I participated in the USA Computing Olympiad in high school and went from a nobody to top 20 in the US. In terms of "real world" programming, I think I can say with utmost confidence that my skills have been significantly sharpened. Now I'm not saying everyone should go out and do what I did, but I think it's worth spending some time honing your problem solving skills. You can really learn a lot and it's definitely applicable to software development.
    – tskuzzy
    Aug 8, 2011 at 18:24

This particular problem requires you to know basic number theory, specifically ideas like factoring composite numbers, some properties of prime numbers and an understanding of relatively prime pairs of numbers.

The other problems on the site require an understanding big O notation, simple data structures, basic algorithms like sorting, and combinatorics. I've passed 3 of the 5 problems and I'm almost done with my 4th, and I haven't used any specific knowledge from after my first year of CS classes in college. That said, these are difficult problems. Some of them require a surprising amount of mathematical intuition.

To prepare for this sort of stuff, you have to be good at mathematical problem solving. Look into the Olympiad (if you're in high school) or Putnam exam (if you're in college) and do the practice problems you find. They're hard, but you get better at them eventually.

Also, don't do the 30 point question - Quadrant Queries - first. It's the hardest by far.

Not the answer you're looking for? Browse other questions tagged or ask your own question.