Showing posts with label consecutive numbers. Show all posts
Showing posts with label consecutive numbers. 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')

Saturday, 16 December 2017

Building Brilliant Numbers

I shouldn't let the opportunity go by to make a note of today and tomorrow's numbers: 25094 and 25095. Both these numbers belong to the OEIS sequence A108770: numbers n such that \(n^2 + (n+1)^2 \) is a brilliant number. The sequence proceeds:
3, 10, 15, 20, 27, 37, 59, 92, 105, 120, 152, 155, 175, 190, 215, 219, 242, 245, 254, 255, 277, 300, 302, 307, 325, 337, 362, 365, 370, 402, 415, 614, 930, 944, 987, 1049, 1059, 1112, 1192, 1204, 1210, 1220, 1265, 1312, 1344, 1360, 1374, 1449, 1460, 1504, 1527, ...
As can be seen, such numbers are relatively common. 92 is given as an example \( 92^2 + 93^2 = 17113 = 109*157 \) as both of its factors have three digits. 25094 is also in this sequence because \( 25094^2+25095^2 = 1259467861 = 23873×52757 \) but so also is 25095 because \( 25095^2+25096^2 = 1259568241 = 29401×42841 \). These consecutive pairs are relatively rare and those listed are (254,255), (4099,4100), (11159,11160), (25094, 25095), (31754,31755) and (40189,40190) with the conjecture that there are infinitely many of such pairs.

It's a bit of a wait until the next pair (31754 and 31755) but hopefully I'll be around to greet them.