The Puzzle
You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.
Rules
- You are not allowed to use
*
or/
(or any other power or square root operator, such asPOW
orSQRT
, if your language contains such functions) - You may not use a loop, or use a constructions that is similar to a loop. Example of loop like constructions are
GOTO
and recursion.
Example
Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function
Be creative and (ab)use the functions and features given to you by your language of choice.
*edit
Loop like structures are loops that allow you to repeat 1 or more instructions
-if you could add an stdout "1"
to your code and you would end up with repeating that output n times, it will count as a loop