What is that? It's the piece of code we wrote for computing square roots, square roots of actually perfect squares.
对吧?这是什么呢?,这是我们写的计算平方根的代码,计算完全全平方根的。
All right, this is actually a very old piece of imperative knowledge for computing square roots, it's attributed to Heron of Alexandria, although I believe that the Babylonians are suspected of knowing it beforehand.
好,这是一个很古老的,关于计算平方根的程序性知识,是亚历山大的海伦提出的,不过我怀疑在那之前,巴比伦人就已经猜想过了。
You know, if you're wandering through Harvard Square and you see an out-of-work Harvard grad, they're handing out examples of square roots, they'll give you an example and you can test it to see is the square root of 2, 1.41529 or whatever.
你知道,如果你从哈佛校园里穿过去,你看见了一个失业校友,正在派发平方根的示例,他们会给你一个例子,而你会检查2的平方根是1。41529或者别的什么。
Suppose I want to compute square roots a lot of places in a big chunk of code.
假设我想在一大段代码中,计算很多次平方根。
This was using something called a bisection method, which is related to something called binary search, which we'll see lots more of later, to find square roots.
你应该想起来,我们是以一个,叫做二分法求平方根的问题结束的,它运用了二分法去求一个数的平方根,二分法和我们将要花很多时间。
This tells you how to find square roots.
这个让你知道怎样寻找平方根。
It doesn't help you find square roots.
它不会帮你算出平方根。
And if I were to use that again, I'd just put it on your handout, I could go back and rewrite that thing that I had previously for finding the square roots of the perfect squares, just using the FOR loop. OK. What I want to do, though, is go on to-- or, sorry, go back to - my divisor example.
它可以是任意的集合,如果我又要去用这个方法的话,我会把它放在你们的课堂手册上的,我可以回过头去用FOR循环,重新写我们那个求平方数的程序,我想要做的是,是继续-哦抱歉,回到-我的除数那个例子。
应用推荐