harshad | R Documentation |
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.
harshad(x, base = 10)
x |
The integer, |
base |
The base of the input |
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.
A single item equal to one if the input is Harshad and equal to zero if not.
Carl Witthoft, carl@witthoft.com
https://en.wikipedia.org/wiki/Harshad_number
harshad(20)
# [1] 1
# 2 + 0 = 2, divides 20
harshad(37,base = 8)
#[1] 0
# 3 + 7 = 12 base8 , does not divide 37 base8 (in base 10, 10 does not divide 31)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.