Skip to main content
2 of 8
added 24 characters in body
dwana
  • 551
  • 4
  • 8

Calculate power of 2

The puzzle

Write a function p(n) that returns n^2

with n is an positive integer or 0

Rules

You can't use * or / (or power or square root operator if the language has one)

You can't use a loop or loop like constructions

You can't use POW or SQRT functions

Example

Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function

So be creative and (ab)use some functions/features ^^

*edit removed wrong tag and editted rule

dwana
  • 551
  • 4
  • 8