So, I was off hunting for another obfuscation/golfing challenge for myself and was thinking about writing up an abundant number generator (I'd discovered an old app I'd done as a wee college student in pascal for my CS 112 class), but considered it too simple a task. A little digging around yielded weird numbers, which are, of course, abundant numbers which are not semi-perfect.

So now I give you, in only 176 characters, a weird number generator.

```
{\$s=eval join'+',@d=grep!(\$n%\$_),1..
++\$n-1;eval{w(@d,\$n)if\$s>\$n};print\$n
,\$/if\$@=~/!/;redo}sub w{my\$s=pop||
die;my\$t=pop||die'!';eval{w(@_,\$s-\$t
)},\$@=~/!/||die if\$t<=\$s;w(@_,\$s)}

Note that with only small modifications, this script can also easily print out deficient numbers, abundant numbers, perfect numbers, semi-perfect numbers, multiply perfect numbers, and who knows how many other variations on the theme. A more interested party may try stepping in to upgrade this program to print out this information (6 P, 10 D, 12 A, 20 S, 70 W, 120 3P, and so on) for all numbers it encounters.

Update: Shaved off a character.

Update 2: Shaved off 10 more characters.

Update 3: Shaved off another 13 characters. Obviously, this wasn't as golfed as I'd originally thought. Wow.

Update 4: Added in another example, explaining Limbic~Region's example set below

Replies are listed 'Best First'.
Re: Weird number generator
by Limbic~Region (Chancellor) on Oct 24, 2006 at 16:29 UTC
jimt,