This function tests whether the input is a Harshad number in the specified base. If the input divided by the sum of the digits (in the base) is an integer, then it is a Harshad number.
Usage
harshad(x, base = 10)
Value
A single item equal to one if the input is Harshad and equal to zero if not.
Arguments
x
The integer, bigz or character string representing the integer to test.
base
The base of the input x . Bases 2 through 36 are supported.
The harshad sequence follows simple rules:
Take the digits of a number in the specified base and sum them. Divide the input value by that sum. If the result is an integer, i.e. the sum divides the input, it's a Harshad number.