Post Reply 
digits in x
11-23-2015, 11:58 AM (This post was last modified: 11-23-2015 11:59 AM by fhub.)
Post: #11
RE: digits in x
(11-22-2015 06:33 PM)ggauny@live.fr Wrote:  I was not thinking in 10 powered, because in Kaprekar number it is not possible (I think).
You're right, powers of 10 are no Kaprekar numbers by definition.

BTW, here's my final version for Kaprekar numbers - different to my first version that I've sent you via PM (with 22 steps, optimized for size), this version is MUCH faster, but has 37 steps (now also showing the first number 1, without 1 you could even save 3 more steps 0004-0006).
Code:

/*
  Next Kaprekar number

  Input:  X:n (start number: 0<=n<999999)
  Output: X:k (next Karprekar number k>n)
          R/S --> next number ...
*/

0001 ****LBL'KAP'
0002 LocR 003
0003 STO .00
0004 INC X
0005 x=1?
0006 RTN
0007 **LBL 00
0008 INC .00
0009 RCL .00
0010 # 009
0011 MOD
0012 x[<=]1?
0013 SKIP 002
0014 RCL- L
0015 STO- .00
0016 RCL .00
0017 x[^2]
0018 STO .02
0019 EXPT
0020 10[^x]
0021 SDL 001
0022 STO .01
0023 **LBL 01
0024 [cmplx]RCL .01
0025 SDR 001
0026 STO .01
0027 IDIV
0028 x[>=]? .00
0029 GTO 00
0030 [cmplx]RCL .01
0031 MOD
0032 x=0?
0033 GTO 00
0034 +
0035 x[!=]? .00
0036 GTO 01
0037 END

Franz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
digits in x - ggauny@live.fr - 11-22-2015, 04:29 PM
RE: digits in x - Didier Lachieze - 11-22-2015, 04:58 PM
RE: digits in x - ggauny@live.fr - 11-22-2015, 05:22 PM
RE: digits in x - fhub - 11-22-2015, 05:40 PM
RE: digits in x - Marcus von Cube - 11-22-2015, 05:43 PM
RE: digits in x - Dieter - 11-22-2015, 05:49 PM
RE: digits in x - Marcus von Cube - 11-22-2015, 05:51 PM
RE: digits in x - Didier Lachieze - 11-22-2015, 05:56 PM
RE: digits in x - ggauny@live.fr - 11-22-2015, 06:33 PM
RE: digits in x - fhub - 11-23-2015 11:58 AM
RE: digits in x - ggauny@live.fr - 11-24-2015, 09:34 AM
RE: digits in x - Dieter - 11-22-2015, 05:46 PM
RE: digits in x - ggauny@live.fr - 11-23-2015, 04:48 PM
RE: digits in x - ggauny@live.fr - 11-24-2015, 11:05 AM
RE: digits in x - fhub - 11-24-2015, 12:07 PM
RE: digits in x - ggauny@live.fr - 11-24-2015, 07:03 PM
RE: digits in x - ggauny@live.fr - 11-24-2015, 07:39 PM



User(s) browsing this thread: 1 Guest(s)