bink@aplcen.apl.jhu.edu (Ubben Greg) (03/17/89)
In article <93227@sun.uucp> landauer@sun.UUCP (Doug Landauer) writes: >Anyway, I haven't seen any other postings that solve this silly >challenge (to write a little factorial program) in as few characters as >does this 76-character shell/dc/sed script: >---- >dc<<Q >[[error]pq]se`head -1`dsnd1>ed9<e[ln1-dsn*ln2<y]syln2<y[answer is ]Pp >---- >Can anyone improve this further? Being somewhat of a {sh,sed,dc,awk,etc} fanatic, I couldn't resist playing with Doug's script, coming up with the following version which is only 53 characters long (if you remove the trailing newline): ?[[error]pq]sad1>ad9<a[d1-d2<a*]sad2<a[answer is ]Ppq This is a pure dc program, so invoke it as "dc f.dc". I mainly eliminated the lengthy register references by using non-tail recursion. By the way, this is my first posting. Hi Mom! -- Greg Ubben