from math import exp
import math
tolerance = (0.1)**10
a=0.5
b=exp(1)
times=0
sol=0
for i in range(500):
p=(a+b)/2
if abs(a-b)<tolerance:
sol=p
break
else:
if math.log(p)*math.log(a)<0:
a=a
b=p
if math.log(p)*math.log(b)<0:
a=p
b=b
times+=1
print(times)
왜 range는 100번이나 500번이나 차이가 없고 break문은 왜 넣나요??
돌로렌스 캐년..
특정 알고리즘 구현 같은데 어차피 100번 안에 수렴하면 몇 번 만에 돌리건 상관이 없지. break는 원하는 결과가 나오면 그 때 루프 깨려고 하는거고
다시 보니 그냥 이분탐색 같은데 취해서 자세히 보기가 귀찮다