An alternative way to calculate squares.. without using multiplication
www.emilkirkegaard.com
I was once at a party, and i was somewhat bored and i found this way of calculating the next square. It works without multiplication, so its suitable for mental calculation. Seeing that i have recently learned python, here's a python version of it: n = 10 # how many sqs to return b = [] def sq(x): return x*x for y in range(1,n): print sq(y) b.append(sq(y)) def sqx(x): if x == 1: return 1 if x == 2: return 4 return (sqx(x-1)-sqx(x-2))+sqx(x-1)+2 a = [] for y in range (1,n): print sqx(y) a.append(sqx(y))
An alternative way to calculate squares.. without using multiplication
An alternative way to calculate squares…
An alternative way to calculate squares.. without using multiplication
I was once at a party, and i was somewhat bored and i found this way of calculating the next square. It works without multiplication, so its suitable for mental calculation. Seeing that i have recently learned python, here's a python version of it: n = 10 # how many sqs to return b = [] def sq(x): return x*x for y in range(1,n): print sq(y) b.append(sq(y)) def sqx(x): if x == 1: return 1 if x == 2: return 4 return (sqx(x-1)-sqx(x-2))+sqx(x-1)+2 a = [] for y in range (1,n): print sqx(y) a.append(sqx(y))