12
\$\begingroup\$

SUNCE MEH BEEN WRUTEN CODEZ IN MUNY DIFFRNT PROGRAMMING LANGUAGES, MEH THOUGHTZ THAT ME TRY TO WRITE CODEZ IN AN ESOTERIC LANGUAGE. MEH CODEZ CALCULUTS A FAWCTORIAL OF UH USR INPUTTED NUMBAH IN LOLCODE, LOL.

SOME OF MEH QUSTIONS:

  • IZ MEH CODEZS A IDMITIC LOLCAT PROGUM?
  • IZ THERE A GOODER WAY OF WRUTING MEH factorial FUNCSHUNS?

TRANSLATION:


Since I've been writing and trying programs in many different languages, I thought I'd give esoteric language a crack. So I used LOLCODE to write a program that calculates the factorial of a user given number:

Questions for consideration:

  • Is my LOLCODE code idiomatic to the LOLCODE language?
  • Is there a easier way to write my factorial function?

LOLCAT.lol

BTW Calculates the factorial for a user given integer

BTW Author: Pythonic
BTW Version: 1.0


HAI 1.2
HOW DUZ I factorial YR n
    BOTH SAEM n AN 0, O RLY?
        YA RLY
            FOUND YR 1
        NO WAI
            FOUND YR PRODUKT OF n AN factorial DIFF OF n AN 1
    OIC
IF U SAY SO

HOW DUZ I main
    I HAS A user_input

    VISIBLE "ENTER AN NUMBAH"
    VISIBLE "TO FINDZ ITZ FAWCTORIAL:: "

    GIMMEH user_input

    VISIBLE "DE FAWCTORIAL OF " user_input " IZ:: " factorial user_input
    VISIBLE "KTHXBYE!"
IF U SAY SO

main
KTHXBYE

For those of you who are not fortunate enough to have a LOLCODE compiler, here is a link to a REPL.IT of the code.

NOTE: All answer must be given in proper LOLCODE English, with an optional translation in regular English. Failure to do so will result in me releasing my LOLCATS upon you....

\$\endgroup\$
  • 3
    \$\begingroup\$ user_input in lolcode ??? YU_TOLD? \$\endgroup\$ – Máté Juhász Oct 14 '16 at 6:39
7
\$\begingroup\$

Your factorial function enters an infinite loop if passed a negative integer. Since the entire program seems to take 1 input and then exit, I think it would be best if the program gave an error message and then exited.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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