2014-09-24

# Problem 038: Pandigital multiples

Description:

Take the number 192 and multiply it by each of 1, 2, and 3:

``````192 × 1 = 192
192 × 2 = 384
192 × 3 = 576``````

By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)

The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).

What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n > 1?

Solution:
v#########
v#########    v                                                                                                                                              <#     p145<
#########         v          +1<           v            <  v               <                 vp2\0:<         >v    >v          >\$v   v\g2:<
>"ec"*31p>241p>01-1>:31g*\:41g-#^_\$>\10p01-\>:55+%\55+/:#^_\$>10g55+*+10p:1+#^_\$10g\:1+#v_\$:55+>  1-:|  >:55+%:|>:2g!|>1\2p55+/:!| >55+> 1-:|>#v_\$41g1-:41p1-#^_31g1-:31p|
^                                                  \<           \$>\$:^      \$#    \$#          <v++++++++\$<
\$\$>     >          \$0>9-!\\$     ^ >.     @     ,,,,, "RORRE"<
Start
??
Pause
Reset
Output:
Stack:   (0)

Explanation:

Not much to say here. I needed to implement a way of merging numbers and a way of testing for pandigitals (we already did that in problem 32). Then we start from `9999` downward, because bigger numbers will always lead to 10 digits or more.

 Interpreter steps: 3 567 967 Execution time (BefunExec): 624ms (5.72 MHz) Program size: 169 x 6 Solution: 932718654 Solved at: 2014-09-24

made with vanilla PHP and MySQL, no frameworks, no bootstrap, no unnecessary* javascript