Page 1 of 1

1. Write a program with two functions that do the same work (described below) - one must be recursive and one should use

Posted: Mon May 09, 2022 8:00 am
by answerhappygod
1 Write A Program With Two Functions That Do The Same Work Described Below One Must Be Recursive And One Should Use 1
1 Write A Program With Two Functions That Do The Same Work Described Below One Must Be Recursive And One Should Use 1 (64.43 KiB) Viewed 24 times
1 Write A Program With Two Functions That Do The Same Work Described Below One Must Be Recursive And One Should Use 2
1 Write A Program With Two Functions That Do The Same Work Described Below One Must Be Recursive And One Should Use 2 (64.43 KiB) Viewed 24 times
1. Write a program with two functions that do the same work (described below) - one must be recursive and one should use a loop. Your main should read in an integer, print it out, then print out the number of digits in the integer (twice) by calling the two functions. Each function should return the number of digits in the integer. Note that the two numbers should be the same - your task is to do it both recursively and with a loop, one function for each. 2. Write a recursive function to determine and return the sum of the first n positive integers. Read the value of n from the keyboard. (For example, for n=100 the sum is 5050) 3. The greatest common divisor of integers x and y is the largest integer that evenly divides both x and y. Write a recursive function gcd) that returns the greatest common divisor of x and y. The god of x and y is defined recursively as follows: if y is equal to 0, then god (x, y) is x; otherwise gcd (x, y) is gcd (y, x%y) where % is the remainder operator.