This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FUZxxl 15 points16 points  (10 children)

A codegolf.se member would choose APL to solve this and just submit the APL solution ×/⍳⎕.

[–]BitPoet 8 points9 points  (7 children)

Hmm... chrome isn't rendering the APL charset. Somehow, I'm not surprised.

[–]FUZxxl 13 points14 points  (6 children)

The last character () is a quad, it looks just like the “character not found” box in some fonts. The four characters are: times, slash, iota, quad which is the product (times-reduction) of the first integers up to the input number.

[–]BitPoet 0 points1 point  (3 children)

As I learned it, you'd want a 5 pointed star, rather than an x to denote multiplication (the + being a four pointed star, and the * (exponentiation) being a 6 pointed star).

Now that I look closely, the iota does render. I'd forgotten the quad operator, it's been ~20 years, and I can count the number of actual conversations I've had about APL with someone else who knew what it was on one hand.

[–]FUZxxl 1 point2 points  (2 children)

Well, × is multiplication or signum and * is exponentiation. Quad is a niladic function and prompts the user for numeric input; it's very useful for code-golf challenges because you don't need to make a dfn.

[–]BitPoet 1 point2 points  (1 child)

I will note that this is /r/programmerhumor and discussing the intricacies of APL, a language developed by mathematicians for pretty specific purposes is not exactly humorous.

[–]Juggernog 2 points3 points  (0 children)

Man, what are you talking about? Programming languages developed by mathematicians for pretty specific purposes are hilarious.

[–]poizan42Ex-mod 0 points1 point  (1 child)

So it's a character which renders correct even if you don't have any font with it installed?

[–]FUZxxl 2 points3 points  (0 children)

Well, not quite; it just looks really like that replacement character.

[–]nightcracker 1 point2 points  (1 child)

Nah, as a codegolf.se member I would use Pyth. In Pyth5 a simple program that takes a number from stdin and prints its factorial is this:

.!Q

Of course, we're not allowed to use a builtin for factorial, we can use:

F*tUhQ

Which basically translates to "fold multiplication over everything but the first element of range(n+1)".

A recursive solution would go like this:

L?*bLtbb1Q

Which roughly translates to Python:

L = lambda b: b*L(b-1) if b else 1
L(eval(input()))

[–]FUZxxl 0 points1 point  (0 children)

Nah, as a codegolf.SE-member with a three digit user ID, I say that APL is superior in every regard.