### Search

 Search WWW Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

Support DFF - Shop

If you shop at Amazon anyway,  consider using this link.

We receive a few cents from each purchase.  Thanks

### Support DFF - Donate

If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

(Hint: If you can wait, current year calendars are usually on sale in January.)

### Contact

 Search DelphiForFun.org only

### Problem Description

Here's a simple little program to solve this problem:  "There is only one set of 3 different two-digit 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 & Techniques

There 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 n-digit positive integers lies between the smallest and the largest so will also be an n-digit number. This lets us just check if the means are integers and in the 2-digit 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 2-digit primes.  It returns false otherwise.

100 or so lines of code make this an Intermediate level program.