美文网首页
不完全立方根穷举法求解

不完全立方根穷举法求解

作者: 大师的学徒 | 来源:发表于2020-03-15 00:49 被阅读0次
    cube = 8120601
    epsilon = 0.01
    guess = 0.0
    increment = 0.0001
    num_guesses = 0
    # while abs(guess ** 3 - cube) >= epsilon and guess < cube:
    while cube - guess**3 >= epsilon:
        guess += increment
        num_guesses += 1
    print('Guesses %d times.' % num_guesses)
    print(guess,"is close to the cube root of", cube)
    
    

    相关文章

      网友评论

          本文标题:不完全立方根穷举法求解

          本文链接:https://www.haomeiwen.com/subject/dsvashtx.html