18
votes
\$\begingroup\$

The challenge:

Write a program or a function that inputs a positive number and returns its factorial.

Note: This is a question. Please do not take the question and/or answers seriously. More information here. Every question is also a question, so the highest voted answer wins.

\$\endgroup\$
4
  • 6
    \$\begingroup\$ See also The Evolution of Haskell programmer. \$\endgroup\$
    – Petr
    Dec 29, 2013 at 7:46
  • 4
    \$\begingroup\$ -1, sorry, because we're getting a huge flood of these code trolling questions and this does not really add anything new to them \$\endgroup\$
    – Doorknob
    Dec 29, 2013 at 11:25
  • \$\begingroup\$ Related: codegolf.stackexchange.com/questions/1635/forking-factorials \$\endgroup\$
    – Paul
    Dec 30, 2013 at 10:08
  • \$\begingroup\$ Code-trolling is in the process of being removed, as per the official stance. This question has a fair amount of votes with many answers, many of which are extremely highly voted. It recieved just over 50% "delete" votes on the poll, but it is unique in that it recieved so many answers and votes, so I am locking it for historical significance. \$\endgroup\$
    – Doorknob
    May 12, 2014 at 0:13

61 Answers 61

1 2
3
-1
votes
\$\begingroup\$

Javascript

The solution is very easily done using a while loop
function f(n){ var e = n; while (n--){ if (n < 1) break; e*=n;} return e}

\$\endgroup\$
1
  • 4
    \$\begingroup\$ Welcome to PP&CG, @BenJohnsonmk2. You should read up on what code-trolling questions require of their answers. An answer should "give code that works, but is useless, severely frustrating the OP." Your answer needs work! You can edit your answer at any time to make it "better". Cheers. \$\endgroup\$ Jan 13, 2014 at 1:05
1 2
3

Not the answer you're looking for? Browse other questions tagged or ask your own question.