Question: C++ language. please provide detailed comments (for beginners) and use easy to understand/trace code. Thank you ------------------ b-Harshad numbers A b-Harshad number is an integer

C++ language. please provide detailed comments (for beginners) and use easy to understand/trace code.

Thank you

------------------

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 number.

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!