[Home] [Puzzles & Projects] [Delphi Techniques] [Math Topics] [Library] [Utilities]
Which positive 3-digit integer has the most positive integer divisors?
Source: Based on "2001 Mensa Puzzle Calendar" puzzle for October 13
Background & Techniques
Here's a problem that's simple to solve with a program but not easy with pencil & paper. There may be a trick to solve it simply by hand, but I haven't found it.
For this program, we'll just try all integers, n, from 100 to 999 in a loop and for each n check all divisors from 1 to n / 2. To satisfy the requirements of the problem, all we have to do is check the number of divisors found for each n against maxdivisors, the maximum found so far. and save n and maxdivisors whenever a higher value is found.
Delphi's remainder function. mod, is the easy way to check for divisors, if "number mod trialdivisor = 0" then trialdivisor is a divisor.
We'll add a few more lines of code here to display the divisors, just in case someone wants to check our answer.
Running/Exploring the Program
Suggestions for Further Explorations
Copyright © 2000-2013, Gary Darby
All rights reserved.