puts 'Ведіть значення a' a=gets.to_f puts 'Введіть значення b' b=gets.to_f puts 'Введіть значення ε' eps=gets.to_f if (a==b or eps<=0) puts 'Хибні вхідні дані' elsif(a*a-2 == 0) puts a elsif(b*b-2 == 0) puts b elsif((a*a-2)*(b*b-2)>0) puts "Можливо, розв'язків немає" end if ((a*a-2)*(b*b-2)<0) c=(a+b)/2 while (((c*c-2)!=0)and((a-b)*(a-b)>=eps*eps)) c=(a+b)/2; if ((c*c-2)*(a*a-2)>0) a=c else b=c end end puts c end