1 (Find numbers divisible by 5 or 6, but not both) Write a program that displays all the numbers from 100 to 200, ten per line, that are divisible by 5 or 6, but not both. Numbers are separated by exactly one space.
2 (Find the smallestn such that n2 712,000) Use a while loop to find the smallest integer n such that n2 is greater than 12,000.
3 (Find the largestn such that n3 612,000) Use a while loop to find the largest integer n such that n3 is less than 12,000.
4 (Compute the greatest common divisor) Another solution for Listing 5.9 to find the greatest common divisor of two integers n1 and n2 is as follows: First find d to be the minimum of n1 and n2, then check whether d, d-1, d-2, . . . , 2, or 1 is a divisor for both n1 and n2 in this order. The first such common divisor is the greatest common divisor for n1 and n2. Write a program that prompts the user to enter two positive integers and displays the gcd.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here