Square a number: awful answers only

mellen

Matt Ellen-Tsivintzeli

Posted on November 13, 2020

Square a number: awful answers only

Today's challenge is deceptively simple. Square a number. Given the input of an integer, output that integer multiplied by itself.

E.g.

square(3);
//output: 9
square(15);
//output: 225
Enter fullscreen mode Exit fullscreen mode

Of course, I only want to see the worst ways to do this. Don't hold back. Make the compiler beg for mercy! You might find inspiration in the Wikipedia article on squaring.

Tests

square(4) == 16;
square(16) == 256;
square(51) == 2601;
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
mellen
Matt Ellen-Tsivintzeli

Posted on November 13, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Sleeps until Christmas: awful answers only
challenge Sleeps until Christmas: awful answers only

December 22, 2022

Square a number: awful answers only
challenge Square a number: awful answers only

November 13, 2020