Write a recursive function moreFactors(a,b,fact) that does the
following:
1. Takes as an input 3 positive integers. (1 pts)
2. Of the two integers a and b, the function returns the integer
that has the most factors fact. (5 pts)
3. If both integers a and b have the same amount of factors fact,
the function will return the larger integer. (2
pts)
Test your function with the following: (2 pts)
>> result=moreFactors(24,32,3)
result =
24
(24 = 31 23, 32 = 25)
>> result=moreFactors(32,24,3)
result =
24
>> result=moreFactors(80,168,2)
result =
80
(80 = 24 5, 168 = 23 3 7)
>> result=moreFactors(100,50,5)
result =
100
(100 = 22 52, 50 = 2 52)
Note: Your function must be recursive! If your function does not
use recursion, up to 8 points may be deducted from
your total.
Write a recursive function moreFactors(a,b,fact) that does the following: 1. Takes as an input 3 positive...
Write a recursive function named multiply that takes two positive integers as parameters and returns the product of those two numbers (the result from multiplying them together). Your program should not use multiplication - it should find the result by using only addition. To get your thinking on the right track: 7 * 4 = 7 + (7 * 3) 7 * 3 = 7 + (7 * 2) 7 * 2 = 7 + (7 * 1) 7 *...
****python****
Q1.
Write a recursive function that returns the sum of all numbers
up to and including the given value.
This function has to be recursive; you may not use loops!
For example:
Test
Result
print('%d : %d' % (5, sum_up_to(5)))
5 : 15
Q2,
Write a recursive function that counts the number of odd
integers in a given list.
This function has to be recursive; you may not use loops!
For example:
Test
Result
print('%s : %d' % ([2,...
Please solve the program in C++(Recursive) Write a function called factorialIterative(). This function should take a single BIG integer (bigint) as its parameter n, and it will compute the factorial n! of the value and return it as its result (as a bigint). Write this functions using a loop (do not use recursion). 2. Write the factorial function again, but using recursion. Call this function factorialRecursive(). The function takes the same parameters and returns the same result as described in...
Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...
In Python 3
(2.5 pts] Write the recursive function thirtyTwos(n) that takes an integer greater or equal to 0 and returns an integer that represents the number of times that a 2 directly follows a 3 in the digits of n. Hint: The % and // operations from sumDigits could be helpful here >>> thirtyTwos (132432601)
20. [5 points] Rewrite the following ML. function using patterns fun factn. ifn-0 then 1 else n fact (n-1) 21. [S points) Using map function, write an ML function int2real of type int list real list that takes a list of integers and returns the same numbers converted to real. For example, if the input is [1,2,3], the output should be like [1.0,2.0,3.0 22. [5 points] Using foldr function, write a function duplist of type·a list 'a list that takes...
d printAllIntegers () Write a C++ program that defines and tests a function largest(....) that takes as parame- ters any three integers and returns the largest of the three integers. Your output should have the same format and should work for any integers a user enters Desired output: Enter three integers: 6 15 8 The largest integer is: 15 7.3 Recursive Functions Write a program that uses a function sum(int) that takes as an argument a positive integer n and...
Write a C++ program that does the following : 1. Accepts array size from the keyboard. The size must be positive integer that is >= 5 and <= 15 inclusive . 2. Use the size from step 1 in order to create an integer array. Populate the created array with random integer values between 10 and 200. 3. Display the generated array. 4. Write a recursive function that displays the array in reverse order . 5. Write a recursive function...
Write c++ recursive function 3. A function that takes an integer, and returns the product of the digits, so the input 1989 would return 1∗9∗8∗9 = 648 4. A function that does the above repeatedly, taking a number and computing the product of it’s digits until you get a single digit number: so on input 1989 it would go 1989→648→192→18→8 and return 8. (Note, you can use the previous functions if you want.
please explain each line of code! ( in python
)
1. Write a recursive function that returns the sum of all even integers in a LinkedBinaryTree. Your function should take one parameter, root node. You may assume that the tree only contains integers. You may not call any methods from the LinkedBinaryTree class. Specifically, you should traverse the tree in your function def binary tree even sum (root): Returns the sum of al1 even integers in the binary tree 2....