Showing posts with label harshad number. Show all posts
Showing posts with label harshad number. Show all posts

Saturday, 30 June 2018

Harshad Numbers Revisited

On the 10th February 2017, I posted about Harshad numbers, also known as Niven numbers, that are defined to be those numbers that are divisible by the sum of their digits in a given base. The post featured 24786 which was the last of the right-truncatable Harshad numbers (in base 10). Since then I've not been reminded of such numbers until I only recently came across the Numbers Aplenty website (see recent post). The reason for the disappearance of the Harshad numbers from the OEIS is that they are relatively frequent and so do not appear in a search of its database. Only the following numbers are listed:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100, 102, 108, 110, 111, 112, 114, 117, 120, 126, 132, 133, 135, 140, 144, 150, 152, 153, 156, 162, 171, 180, 190, 192, 195, 198, 200, 201, 204

However, the OEIS entry does contain a link to all the Harshad numbers less or equal to 100,000. There are 11,872 of them and so there density is slightly less than 12% in that range. My number for today, 25290, appears in that list in position number 3771. However, I was only aware of this because of the Numbers Aplenty entry for 25290. The OEIS is definitely limited when it comes to searching for properties of numbers in this region of the number line and beyond.

The Numbers Aplenty reference to Harshad numbers contains some interesting additional information to what I posted in my earlier blog. For example, it is possible to have at most twenty consecutive Niven numbers and this happens infinitely often. Below is a list of runs of up to 13:


Wikipedia states that more generally there are 2b but not 2b + 1 consecutive b-harshad numbers, so that for example there can be runs of up to 22 11-harshad numbers, 24 12-harshad numbers and so on. Harshad numbers fall into the category of recreational mathematics.

While it's rather easy to determine whether a number is Harshad or not, nonetheless here is the SAGE code that I developed to test "harshadness":
INPUT
#Test for Harshad Number, divisible by sum of digits
number=25290
sum=0
nu_str=str(number)
for d in nu_str:
    sum+=Integer(d)
if number % sum == 0:
    print(number, "is Harshad Number")
else:
    print(number, "is not a Harshad Number")
 
OUTPUT
(25290, 'is Harshad Number')

Sunday, 24 June 2018

Numbers Aplenty

Today I just stumbled upon a new site that lists information about natural numbers. It's called Numbers Aplenty.


The categories under which numbers are classified looks like this:


So for instance, today I am 25284 days old and entering that number into the search box yields:
  • 25284 has 36 divisors (see below), whose sum is σ = 70224. Its totient is φ = 7056. 
  • The previous prime is 25261. The next prime is 25301. The reversal of 25284 is 48252 
  • Adding to 25284 its reverse (48252), we get a triangular number (73536 = T383). 
  • It is a Harshad number since it is a multiple of its sum of digits (21). 
  • 25284 is a Rhonda number in base 10. 
  • Its product of digits (640) is a multiple of the sum of its prime factors (64). 
  • It is a nialpdrome in base 14. 
  • It is a self number, because there is not a number n which added to its sum of digits gives 25284. 
  • It is an unprimeable number. 
  • It is a polite number, since it can be written in 11 ways as a sum of consecutive naturals, for example, 567 + ... + 609. 
  • 225284 is an apocalyptic number. 
  • It is an amenable number. 
  • It is a practical number, because each smaller number is the sum of distinct divisors of 25284, and also a Zumkeller number, because its divisors can be partitioned in two sets with the same sum (35112). 
  • 25284 is an abundant number, since it is smaller than the sum of its proper divisors (44940). 
  • It is a pseudoperfect number, because it is the sum of a subset of its proper divisors. 
  • 25284 is a wasteful number, since it uses less digits than its factorization. 
  • 25284 is an evil number, because the sum of its binary digits is even. 
  • The sum of its prime factors is 64 (or 55 counting only the distinct ones). 
  • The product of its digits is 640, while the sum is 21. 
  • The square root of 25284 is about 159.0094336824. The cubic root of 25284 is about 29.3504835430. 
  • The spelling of 25284 in words is "twenty-five thousand, two hundred eighty-four".
Many of the terms mentioned above I'd never heard before. The site will be a useful adjunct to the Online Encyclopedia of Integer Sequences or OEIS.

Saturday, 11 February 2017

Harshad Numbers

Today I turned 24786 days old and one of the occurrences of this number in the OEIS was in A097569: right-truncatable Harshad numbers (zeros not permitted). Of course, I needed to ask myself the inevitable question: what is a Harshad number? Here is what Wikipedia had to say about it:
In recreational mathematics, a harshad number (or Niven number) in a given number base, is an integer that is divisible by the sum of its digits when written in that base. Harshad numbers in base \(\displaystyle n\) are also known as \(\displaystyle n\)-harshad (or \(\displaystyle n\)-Niven) numbers. Harshad numbers were defined by D. R. Kaprekar, a mathematician from India. The word "harshad" comes from the Sanskrit harṣa (joy) + da (give), meaning joy-giver. The term “Niven number” arose from a paper delivered by Ivan M. Niven at a conference on number theory in 1977. 
Stated mathematically, let \(\displaystyle X\) be a positive integer with \(\displaystyle m\) digits when written in base \(\displaystyle n\), and let the digits be \(\displaystyle a_{i}\) ( \(\displaystyle i\) = 0, 1, ..., \(\displaystyle m\) − 1). (It follows that \(\displaystyle a_{i}\) must be either zero or a positive integer up to \(\displaystyle n\) − 1.) \(\displaystyle X\) can be expressed as \[\displaystyle X=\sum _{i=0}^{m-1}a_{i}n^{i}\]
If there exists an integer \(\displaystyle A\) such that the following holds, then \(\displaystyle X\) is a harshad number in base \(\displaystyle n\): \[\displaystyle X=A\sum _{i=0}^{m-1}a_{i}\] A number which is a harshad number in every number base is called an all-harshad number, or an all-Niven number. There are only four all-harshad numbers: 1, 2, 4, and 6 (The number 12 is a harshad number in all bases except octal).

So, getting back to 24786, it can be seen that it is a Harshad number because 2+4+7+8+6 = 27 and 24786/27 = 918. Truncating the last digit on the right gives 2478, so that 2+4+7+8 = 21 and 2478/21 = 118. Truncating again gives 247, so that 2+4+7 = 13 and 247/13 = 19. Truncating again gives 24, so that 2+4=6 and 24/6=4. Finally, 2 itself is of course a Harshad number.

Furthermore, it is asserted in the OEIS entry that 24786 is the final such number in the sequence of right-truncatable Harshad numbers. The full sequence is then given by:

1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 18, 21, 24, 27, 36, 42, 45, 48, 54, 63, 72, 81, 84, 126, 216, 243, 247, 364, 423, 481, 486, 846, 2478, 8463, 24786