News for hackers. Stuff that matters.
Re:Munchausen Numbers and How to Find Them by zeveb on Wednesday September 21, 2016 @05:03PM (#12552233)
Here's a version in Lisp:

    (defun münchhausen-p (i)
      (eq (loop for number = i then quotient
                for (quotient remainder) = (multiple-value-list (floor number 10))
                sum (expt remainder remainder)
                until (zerop quotient))
          i))
    
    (loop for i from 1 to 500000000 when (münchhausen-p i) do (print i))
It takes .002 seconds to check the first 5,000 integers, 2.108 for the first 5,000,000 and 268.867 seconds for the first 500,000,000.

I'm sure there could be some clever tricks to make it run faster, but this is probably good enough, given that there are, I think, only two such numbers.

Re:Munchausen Numbers and How to Find Them by AnimalMuppet on Wednesday September 21, 2016 @05:31PM (#12552440)
Well, 9^9 = 387,420,489. So a ten-digit Munchausen number that had enough nines in it could be as big as 3,874,204,890. So going to 500,000,000 isn't quite enough. You can stop at 4 billion, though...
Re:Munchausen Numbers and How to Find Them by lispm on Thursday September 22, 2016 @06:32AM (#12555834)
Don't compare numbers with EQ. Use = or EQL.
Re:Munchausen Numbers and How to Find Them by zeveb on Thursday September 22, 2016 @10:56AM (#12557215)
Yup, you're completely correct. I'm a bit embarrassed.