The Babylonian algorithm to compute the square root of a number n is as follows:
1.Make a guess at the answer(you can pick n/2 as your initial guess)
2.Compute r=n/guess
3.Set guess=(guess+r)/2
4.Go back to step 2 for as many iterations asnecessary.The more you repeat step 2
and 3,the closer guess will become to the square root of n.


※Project 3 of Chap. 2.
Write a program that reads in two integers typed on the keyboard and outputs their
sum,difference,and product it.


沒有留言:
張貼留言