Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer in C++. 2 b-harshad numbers A b-harshad number is an integer that is divisible by the sum of its digits when written in
Please answer in C++.
2 b-harshad numbers A b-harshad number is an integer that is divisible by the sum of its digits when written in base b. Examples: 18 is a 10-harshad number, because the sum of the digits 1 and 8 is 9 (1+8 = 9), and 18 is divisible by 9. 19 is not a 10-harshad number, because the sum of the digits 1 and 9 is 10 (1+9 = 10), and 19 is not divisible by 10. 99 is a 7-harshad number, because it is written as 201 in base-7, the sum of the digits 2, 0, and 1 is 3 (2+0+1 = 3), and 99 is divisible by 3. Write a function bool isHarshad (unsigned int n, unsigned int b) that receives as arguments non-negative integers n (in decimal) and b and returns true if n is a b-harshad numberStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started