 # (1) Single digit: Write the code of a recursive function sumToSingl...

## Question

(1) Single digit: Write the code of a recursive function sumToSingleDigit to sum the digits of a number 𝑛 until you are left with a single digit number. Write a test code which takes the value of 𝑛 as input and outputs the single digit sum.
Example Input: 2507
Example Output: 5
Explanation: 2+5+0+7 = 14, 1+4 = 5, 5 is a single digit value output 5

(2) Binary: Write the code of a recursive function decimalToBinary to convert an integer 𝑛 into binary representation. Write a test code to take the value of 𝑛 as input and print the binary value returned by decimalToBinary.
Example Input: 25
Example Output: 11001

(3) Lucky Day
Elsa is a very superstitious girl. Every morning she asks her maid to get N roses from her garden. Then she counts the number of petals of those roses. Elsa calls the day a lucky day if the number of roses with the minimum count of petals is odd, otherwise she considers the day as an unlucky day. Help Elsa in finding if the day is lucky or not.

Input Format:
Take input from the console. First take a value as input to a single integer T denoting the number of test cases. For each test case take an input to a single integer N denoting the total number of roses picked on a day. Next take N integers as input in an array int A[N] denoting the number of petals of those N roses.

Output Format:
For each test case, print "Lucky" (without quotes) if the number of roses with the minimum count of petals is odd, otherwise print "Unlucky"(without quotes). Print a new line after each test case.

Sample Input:
2
5
8 8 9 5 9
5
5 5 5 10 5

Sample Output: Lucky Unlucky

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <stdio.h>
int sumToSingleDigit(int);

int sumToSingleDigit(int number){

if(number/10 == 0){
return number;
}

return sumToSingleDigit(number % 10 + sumToSingleDigit(number/10));
}...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

# 50% discount

Hours
Minutes
Seconds
\$20.00 \$10.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.