# Find the square of a number [duplicate]

Your task is to find the square of a number without using the multiplication sign or division sign

However, to make this even trickier, no use of any addition sign or even the minus sign can be used either

e.g. / // * ** + - are not allowed

no imports are allowed either

An integer will be given in the input

Test cases:

5 -> 25

6 -> 36

10 -> 100

724 -> 524176

This is a extended version of this

• Don't post immediately Jan 10 at 10:19
• i did make sure to check for duplicates tho hopefully there is not duplicate question but sry Jan 10 at 10:20
• R, 1 byte: ^. Are you sure this is a good and well-specified challenge? Jan 10 at 10:25

# Vyxal, 1 byte

²


Try it Online!

# 05AB1E, 1 byte

n


Try it online!

# Ruby, 18 bytes

->a{(1..a).sum{a}}

Attempt This Online!

# Gaia, 1 byte

s


Try it online!

# Integral, 1 byte

4


Try it Online!

# Pip, 4 bytes

SQ:a

Attempt This Online!

# C (gcc), 93 bytes

a(x,y){return y?a(x^y,(x&y)<<1):x;}s(x){return x?a(s((x>0?x:a(~x,2))>>1)<<2,x&1?x<<1^3:0):0;}


Try it online!

a performs addition by using bitwise operations to add and carry for each bit simultaneously and using recursion. s does the squaring: (2n)2 = 4n2 and (2n+1)2 = 4n2 + 4n + 1, with a special case for negative numbers.

# dinoux, 1 byte

²


Try it Online!

# 2sable, 1 byte

n


Try it online!

# Perl 5, 32 bytes

sub{map{map 0,1..$_[0]}1..$_[0]}


Try it online!