05-04-2016 02:13 PM - edited 05-04-2016 02:14 PM
I would give you Kudos Darren for a much simplier code (and faster running) then even I did, but yours is flawed. It doesn't handle numbers larger than an I32 which maxes out with a input of 23.
"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books
05-04-2016 02:20 PM
Oops, I didn't realize the I32 was rolling over. Ok fine, here it is with the math VI inlined so everything can operate on I64.
05-04-2016 11:18 PM
How about bonus points for three different approaches? I haven't benchmarked them against each other or other solutions.