Question: Hello all! Need some assistance with some hw problems - recursion Here are a few problems: Number 1: Sum of Digits - Write a recursive

Hello all! Need some assistance with some hw problems - recursion

Here are a few problems:

Number 1:

Sum of Digits - Write a recursive function that finds the sum of all digits in a multidigit number stored as an int. Note: you cannot convert the data to a string.

Input: 12345

Output: 15

Number 2:

Prime Number - write a recursive function that checks to see if a given integer is prime.

Input: 6

Output: 0

Input: 23

Output: 1

Number 3:

GCD findings - write a recursive function that accepts two integers and returns the greatest common denominator.

Input: 10 45

Output: 5

Input: 121 482731

Output: 1

Number 4:

Unordered permutations - you are tasked with implementing a recursive un-ordered permutation algorithm. Given the value of N, output all permutations of numbers from 1 to N.

Input: 2

Output: 1 2

2 1

Input: 3

Output: 1 2 3

132

213

231

312

321

Anything helps, thanks in advance!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!