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.
- You are not allowed to use
/(or any other power or square root operator, such as
SQRT, 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
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.
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