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


Problem Description
A fifth entry in our "Numeric TShirt" line: Back of TShirt: "The smallest 3digit emirp!" Front: __ __ __ ? Background & TechniquesA "emirp" is a prime number which forms a different prime number when its digits are reversed. (Palindromic primes are excluded by this definition.) Not much new work here  we borrowed the IsPrime and Reverse functions from TShirt #4 . So all that is left for the SearchBtnClick method is to run through a loop looking for primes, checking if the reverse is a prime, and checking that they are not the same. If a number that meets these three conditions, add it to a display list. I added a TUpDown box to select how many digits, N, in the emirps of interest. A 3line IntPower function lets us set the lower limit of our search as 10^{(N1)} and the upper limit at one less than 10 times the lower limit. For 3digit emirps for example, that means that at most we'll search from 10^{(31) }= 10^{2 }= 100 up to 10×1001=10001=999. That pretty much covers the 3digit candidates. We search for emirps up to 9 digits, so we'll limit the display to 100 hits  we really don't need thousands (or millions) of them displayed. About 50 lines of code here, well within the beginner's range. Running/Exploring the Program
Suggestions for Further Explorations

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