26
0
Originally the Multiplicative digital root
Challenge
Basically do what the title says
Method
Given a positive integer 1 <= N <= 100000000 through one of our standard input methods, multiply every digit together, ignoring zeroes.
Ex: Take a number, say 361218402
:
3
*6
=18
18
*1
=18
18
*2
=36
36
*1
=36
36
*8
=288
288
*4
=1152
1152
*1
(ignore zeroes or turn them into ones) =1152
1152
*2
=2304
The output for 361218402
is 2304
Test Cases
1 => 1 every other digit > 0 => itself 10 => 1 20 => 2 100 => 1 999 => 729 21333 => 54 17801 => 56 4969279 => 244944 100000000 => 1
Standard Loopholes are disallowed, and this is code-golf, so shortest byte count wins!
Congrats to Jo King who got the bounty with his 70 byte brain-flak answer!
5I'd rather call this non-zero digital product. "root" suggests it reduces to a single digit, which isn't always true here. – Erik the Outgolfer – 2018-01-15T20:46:32.520
1Can we take input as a string? Or (pushing it) an array of digits? – Shaggy – 2018-01-15T21:19:57.523
@EriktheOutgolfer Yes, however, if you repeat the process enough times, it does appear to always go to a single digit.
– James – 2018-01-15T21:21:17.840You can take quoted input, but no, you can't take a pre-parsed list of digits if that's what you're asking – FantaC – 2018-01-15T21:21:31.390
This seems like a variation on the persistence of a number.
– boboquack – 2018-01-15T22:59:10.4437If we have to support to a max of
100000000000
I suggest the test case99999999999 => 31381059609
, since it doesn't fit in a default 32-bit integer. Perhaps better would be to lower the maximum output to a 32-bit maximum (2147483647). – Kevin Cruijssen – 2018-01-16T08:27:52.237