def h1(n) s = 0 for i in 1..n s = s + i*i end s end def h2(n) s = 0 i = 1 while i <= n s = s + i*i i = i + 1 end s end