It's been a while since I last wrote some lolcode, so I felt like tackling Project Euler #1.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
This is the code/script I wrote to solve this:
HAI 1.2 VISIBLE "HAI, PROJEK LOLLER ONE!!" I HAS A LIMIT ITZ 1000 I HAS A TOTAL ITZ 0 I HAS A CHEEZ ITZ 3 I HAS A BURGER ITZ 5 I HAS A CHEEZBURGER ITZ PRODUKT OF CHEEZ AN BURGER HOW IZ I ADDTOTAL YR VALUE I HAS A RESULT ITZ SUM OF VALUE AN TOTAL FOUND YR RESULT IF U SAY SO IM IN YR MIND UPPIN YR NUMBER TIL BOTH SAEM NUMBER AN LIMIT I HAS A PICKLE ITZ FAIL BOTH SAEM 0 AN MOD OF NUMBER AN CHEEZBURGER O RLY?, YA RLY PICKLE R WIN NO WAI BOTH SAEM 0 AN MOD OF NUMBER AN CHEEZ O RLY?, YA RLY PICKLE R WIN NO WAI BOTH SAEM 0 AN MOD OF NUMBER AN BURGER O RLY?, YA RLY PICKLE R WIN OIC OIC OIC BOTH SAEM PICKLE AN WIN O RLY?, YA RLY TOTAL R I IZ ADDTOTAL YR NUMBER MKAY OIC IM OUTTA YR MIND VISIBLE SMOOSH "TEH ANSWER IZ " AN TOTAL MKAY VISIBLE "DOWN WITH PROJEK LOLLER ONE!" KTHXBYE
This code can be executed on CodingGround, and produces this output:
HAI, PROJEK LOLLER ONE!!
TEH ANSWER IZ 233168
DOWN WITH PROJEK LOLLER!
Is the fizzbuzz-like logic appropriate, or I fell in the "easy" trap? Would there be a way to collapse all the conditions into one and make a shorter script? Or is this algorithm a bad/inefficient one?