def sum(n) #ill args if not (n.is_a?Integer and n>=0) then raise ill arg val end #compute result i=0 s=0 while i