The Babylonian
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 as necessary. The more that steps 2 and 3 are repeated, the closer guess will become to the square root of n.
Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
C How to Program (8th Edition)
C++ How to Program (10th Edition)
Introduction to Programming Using Visual Basic (10th Edition)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out With Visual Basic (8th Edition)
- please solve this in pythonarrow_forwardOur local bank has many customers who save their change and bring it in for deposit. Write a general program to interact with their customers and determine the value of the collection of coins. The algorithm is given as follows: Get and display the customer's initials Get the count of each kind of coin (dollars($), quarter, dime, nickels, cents) • Compute the total value in cents Find the value in dollars and change Display the value in dollars and change Select one:arrow_forwardA Fibonacci sequence is a sequence of numbers where each successivenumber is the sum of the previous two. The classic Fibonacci sequencebegins: 1, 1, 2, 3, 5, 8, 13, .... Write a program that computes the nthFibonacci number where n is a value input by the user. For example, ifn = 6, then the result is 8.arrow_forward
- Find the first 10 square numbers that are greater than Long.MAX_VALUE. A square number is a number in the form of n2. For example, 4, 9,and 16 are square numbers. Find an efficient approach to run your program fast.arrow_forwardAn instructor gives a series of exams during the semester in her math class. At the end of the semester she drops each student's lowest test score before averaging the scores. She has asked you to design a program that will read a student's test scores as input and calculate the average with the lowest score dropped. Here is the algorithm that you developed: Get the student's test scores. Calculate the total of the scores. Find the lowest score. Subtract the lowest score from the total. This gives the adjusted total. Divide the adjusted total by 1 less than the number of test scores. This is the adjusted average. Display the average. The test scores are in a text file named scores.txt and contains the following: Mickey, 71.0, 42.0, 83.0 Donald, 94.0, 73.0, 72.0, 81.0 Minnie, 95.0, 85.0, 45.0, 55.0, 65.0 A sample run is as follows: Enter a file containing floating point numbers: scores.txt Test scores for Mickey: ['71.0', '42.0', '83.0'] Removed the lowest score of 42.0 for Mickey The…arrow_forwardTask 9 Write Python code of a program that reads an integer, and prints the integer if it is a multiple of NEITHER 2 NOR 5. For example, 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39 ... hint(1): use the modulus (%) operator for checking the divisibility hint(2): You can consider the number to be an integer !%3%===== Example01: Input: 3 Output: 3arrow_forward
- In Python input 1 and input 2’s degree is 4 If input 1 and input 2 have same parents, result return 0 Else if input 1 and input 2 have same grandparents , result return 1 Else if input 1 and input 2 have same great_grandparents , result return 2 Else if input 1 and input 2 have same great_great_grandparents , result return 3 Continue until found they have the same great_great_great…._grandparents, For adding one great, result +1 Else: if no relationship between two input, return -1 tree = [[‘Max’, None , None], [‘Luc’, ‘Max’, None], [‘Lue’, ’Max’, None], [‘Joy’, ‘Luc’, ‘Yoyo’], [‘Eva’, ‘Joy’, ‘Zoe’,], [‘Julie’, ‘Geo’, ‘Eva’], [‘input1’, ‘Brand’, ‘Julie’], [‘Jim’, ‘Lue’, ‘Rae’], [‘Gil’, ‘Jim’, ‘Ree’], [‘Rose’, ‘Gil’, ‘Mandy’] [‘input2’, ‘James’, ‘Rose’] this follow by [people, father, mother] Make the function def degree(input1, input 2, tree)arrow_forwardCode the follow.arrow_forwardOn Thursday, November 4, 2021, Big Man Games wrote: Computer programs are great at computing mathematical formulas. Once the formula is properly encoded you can use the code as much as you want without reprogramming it and you can share it with non-programmers without any trouble. This lab is an example of such a formula. Once you program it you won’t have to worry about the area of a circle again. Write and test a program that computes the area of a circle. This program should request a number representing a radius as input from the user. Use the formula 3.14 × radius2 to compute the area. Tip: There are a couple of ways to code an exponent. Look in the Operators unit for help (and you can’t use an x for multiplication). Tip: You will need to use the float data type to compute the remainder. The output should explain the results. Don’t just print a number. Tip: For your print statement you will need to use the comma, “,”, or plus, “+” symbols to stitch your output together. (“The…arrow_forward
- Write a program that generates 50 random numbers such that the first number is between 1 and 2, the second is between 1 and 3, the third is between 1 and 4, . . . , and the last is between 1 and 51.arrow_forward: An ant is sitting on an infinite grid of white and black squares. It initially faces right.At each step, it does the following:(1) At a white square, flip the color of the square, turn 90 degrees right (clockwise), and move forwardone unit.(2) At a black square, flip the color of the square, turn 90 degrees left (counter-clockwise), and moveforward one unit.Write a program to simulate the first K moves that the ant makes and print the final board as a grid.Note that you are not provided with the data structure to represent the grid. This is something youmust design yourself. The only input to your method is K. You should print the final grid and returnnothing. The method signature might be something like void printKMoves ( int K)arrow_forwardWrite a program that counts the number of integers from 1 to M that are divisible by N. Use the sample run as guide. Note, that the program repeats until an invalid input is encountered. Sample run: Program to count the number of integers from 1 to M that are divisible by N. Enter M (>1): 3 Enter N (>1): 4 There are no integers from 1 to 3 that are divisible by 4. Enter M (>1): 4 Enter N (>1): 2 There are 2 integers from 1 to 4 that are divisible by 2. Enter M (>1): 4 Enter N (>1): 3 There is 1 integer from 1 to 4 that is divisible by 3. Enter M (>1): -5 You have entered an invalid input. Program will now terminate.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education