Over at the Project Euler forum a ivan_adrian_k posted a fairly simple question

"Find the only 4-digit integer which the product of its digits is
equal to the first two digits of the number, and the sum of its digits
is equal to the last two digits of the number"

He then goes on to say..
"If you can answer it correctly, can you find all the 5-digit integers
which has similar property, the product of its digits is equal to the
first three digits of the number, and the sum of its digits is equal
to the last two digits of the number?"

NB. Note the answer is inside the link
http://forum.projecteuler.net/viewtopic.php?f=2&t=1869

I am interested in your solutions.

Here is mine - not the most spectacular I must add..

suma=: +/@:((4$10) #: ])
producta=: */@:((4$10) #: ])
lda=: ".2{.":
rda=: ".2}.":
a #~ ( (suma=rda)*.(producta=lda)) "0 (a=.1000+i.9000)

and with a small tweak..

sumb=: +/@:((5$10) #: ])
productb=: */@:((5$10) #: ])
ldb=: ".3{.":
rdb=: ".3}.":
b #~ ( (sumb=rdb)*.(productb=ldb)) "0 (b=.10000+i.90000)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to