Find sum of squares of numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Find sum of squares of numbers

easy code

13th Apr 2018, 10:17 AM
A.V.J.S.Nikhil
4 Answers
+ 2
which language ? in js it could be var a = 2, b = 3; var c = Math.pow(a,2)+Math.pow(b,2); OR var a = 2, b = 3; var c = a*a+b*b; in ruby : a = 2 b = 3 c = a**2+b**2
13th Apr 2018, 10:23 AM
NoxFly
NoxFly - avatar
+ 1
I did this for VcC 's challenge You enter a number and it finds the sum of least squares https://www.sololearn.com/Discuss/1050287/?ref=app https://code.sololearn.com/c6DuuGjp8imR/?ref=app
13th Apr 2018, 2:24 PM
Louis
Louis - avatar
0
c/c++ int a = 2; int b = 3; int c = (a*a) + (b*b);
13th Apr 2018, 10:29 AM
Alex
Alex - avatar
0
In python: S ={2,5,6} def squareSum(S): return sum([x**2 for x in S]) squareSum(S) # correctly returns 65
13th Apr 2018, 11:28 AM
Bebida Roja
Bebida Roja - avatar