Reversed Number

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

 

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.

Mensa 365 Puzzlers  Calendar 2017

Mensa 365 Puzzlers Calendar 2018

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

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

Problem Description

Find a six digit number which, when multiplied by an integer
between 2 and 9 inclusive, gives the original six digit number
with it's digits reversed.

Source: Math and Logic Puzzles for PC Enthusiasts,
J. J. Clessa. Problem # 34.

Background & Techniques

This is an ideal beginner's program illustrating trial and error solution techniques.   Since there are about a million 6 digit integers, (900,000 if we start at 100,000), we should be able try them all in pretty short order.   With each number to be tested, we'll split it into it's component digits, build up a number with the digits reversed, then see if the second is a single digit multiple of the first.   The code provides the best description of the algorithm. 

 I've added QueryPerformanceCounter procedure calls to get run time - about a second to check all 900,000 on  my medium speed Celeron CPU.    And we really don't have to check any higher than 500,000  (why?).

A single procedure (SolveBtnClick) with about 30 lines of user written code keep this one in the beginner's category.   

Running/Exploring the Program 

bulletBrowse source extract 
bulletDownload source 
bulletDownload  executable

Suggestions for Further Explorations

Five or seven digit numbers?  Is there a pattern here?

 

Modified: July 29, 2017

 

 

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.