Re: Programming "Digits exploration"


[Prev][Next][Index][Thread]

Re: Programming "Digits exploration"



On Tue, 13 Aug 1996, Mark Malley wrote:


> AE>Hope you can help me. I wish to write a program that will take a two digit
> AE>number and find the sum of the squares of its digits, take the new number
> AE>and perform the same procedure. My problem is how to 'separate' the digits
> AE>of the number as part of a program.
> Why don't you do something like...
> Prompt A
> Prompt B


If you want to input one number, here is the 'real' math way:


say your nmber is 678


to get the 2nd digit, use this:
(Where x is your number)
(y the digit you want...)


(10*fpart (x/(10^(y-1))))-(fpart (x/(10^(y))))


+------------------------------+-------------------------------+
|        Tony Lieuallen        |   marvin@mars.superlink.net   |
+------------------------------+-------------------------------+
|             http://mars.superlink.net/marvin/home            |
|       http://www.geocities.com/SiliconValley/Park/1171/      |
+-------------------------Finger me for more of what follows!--+
| * It's Non-Toxic! That means you can eat it!!                |
| * The computer saves man a lot of guesswork, but then, so    |
|   does the bikini.                                           |
| * Practice makes perfect, but no one's perfect, so why       |
|   practice?                                                  |
| * The nice thing about Windows is - it does not just crash,  |
|   it displays a dialog box, and let's you press 'OK' first.  |
+--------------------------------------------------------------+


References: