[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]


Problem DescriptionHere's a simple little program to solve this problem: "There is only one set of 3 different twodigit prime numbers with the property that the mean of any two number and of all three are all also prime. What are the numbers?" Background & TechniquesThere are only 21 two digit primes, so we'll build a array containing them and then select all subsets with 3 numbers to check if the means are also prime numbers. The mean of any set of ndigit positive integers lies between the smallest and the largest so will also be an ndigit number. This lets us just check if the means are integers and in the 2digit table of primes. Procedure MakePrimes builds the table of primes by checking integers 11 through 99 that no smaller prime divides it evenly. It calls function IsPrime to perform this test, (B divides A evenly if (A div B)*B=A where "div" is the integer divide operation which returns an integer quotient ignoring any remainders.) Function IsPrimeInteger takes a sum. M, and the number of integers summed, K, as parameters and returns true if K divides M (i.e. the mean is an integer) and M div K is in the array of 2digit primes. It returns false otherwise. 100 or so lines of code make this an Intermediate level program. Running/Exploring the Program
Suggestions for Further Explorations

[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 20002017, Gary Darby All rights reserved. 