Sunday, 28 October 2018

Prime Producing Linear Polynomials

An example of a famous prime producing polynomial is \(n^2-n+41 \) which produces primes for values of \(n\) from 1 to 40. These primes are shown below:
41, 43, 47, 53, 61, 71, 83, 97, 113, 131, 151, 173, 197, 223, 251, 281, 313, 347, 383, 421, 461, 503, 547, 593, 641, 691, 743, 797, 853, 911, 971, 1033, 1097, 1163, 1231, 1301, 1373, 1447, 1523, 1601
Figure 1 is an excerpt relating to this polynomial from an interesting article on prime-generating polynomials:


Figure 1

Figure 2 shows a table of record prime producing polynomials taken from MathWorld:


Figure 2

However, prime producing linear polynomials get less attention than the above quadratic, cubic and higher order polynomials. Today I turned 25410 days old and discovered that the linear polynomial \(25410 \, n+1 \) has some interesting prime producing qualities. Specifically, it produces primes for values of \(n\) from 1 to 6: 25411, 50821, 76231, 101641, 127051, 152461. As it turns out, 25410 is the first coefficient of \(\ a*n+1\) to produce six primes in a row. The next such number is 26040.

OEIS A237190 displays a list of coefficients of of \(\ a*n+1\) that produce five primes in a row:
10830, 25410, 26040, 88740, 165900, 196560, 211050, 224400, 230280, 247710, 268500, 268920, 375480, 377490, 420330, 451410, 494340, 512820, 592620, 604170, 735750, 751290, 765780, 799170, 808080, 952680, 975660, 1053690, 1064190, 1132860, 1156170, 1532370, 1559580
As can be seen, 10830 is the first coefficient with this property. The OEIS entry also provides a list of the first 1000 such coefficients and this is a good starting point when trying to find coefficients that produce six, seven, eight or more primes in a row. With a little manipulation in a spreadsheet, the OEIS data can be pasted directly into a list set up on SageMathCell.

Of the first 1000 coefficients that produce five primes, only the following go on to produce seven primes in a row (in the range 1 to 247289070): 
512820, 8224860, 22240680, 24462900, 26486460, 62871480, 93784530, 99597960, 139819680, 196474950
Of these only the following go on to produce eight primes in a row: 

512820, 22240680, 26486460, 99597960

All four of the above fail to produce a ninth prime. Thus 512820 is the smallest coefficient that will produce eight primes in a row. In terms of primes produced over a given range and not sequentially, it would seem that 15213870 is the most prolific. It produces 40 primes between \(n+1 \) and \(100 \,n+1\) whereas 512820 produces only 33 in the same range.

What do these numbers have in common. To begin with they are all divisible by 30 and are highly factorable. The following table shows the factorisation and number of divisors for the numbers in OEIS A237190:


Figure 3

It would seem that by adding 1 to multiples of such highly factorisable numbers increases the odds of generating a prime number. Interestingly, for the 1000 coefficients mentioned earlier, the polynomial \(25410 \, n+41\) produces a record 41 primes in the range from 1 to 100, more than for any other coefficient. This naturally leads to an investigation of polynomials of the form \(25410 \, n+p\) where \(p\) is prime. Here is a table of what showed up for primes from 2 to 97:


Figure 4

Clearly \(25410 \, n+97\) wins that race and in fact holds the record for all primes below 1000. For primes up to 100000, \(25410 \, n+5471\) takes the lead with 48 primes and only surrenders it to \(25410 \, n+982231\) with 49 primes when considering primes up to one million. Below are the 49 primes generated by \(25410 \, n+982231\) as n ranges from 1 to 100:


Figure  5


Figure 6

I must say that SageMath makes it incredibly easy to investigate matters such as this. Interestingly, of all the possible coefficients from 1 to 999,999, it is \(25410 \, n+982231\) that produces the highest score of 49 primes out of 100. I was beginning to start to think that this might be something of a record until I went back to \(\ a*n+41\) and thought I'd test all the numbers up to 999,999. The table in FIGURE 6 shows the surprising result. 

The factorisations again show the same pattern as with the earlier numbers:
  • 6 = 2 * 3
  • 12 = 2 * 2 * 3
  • 30 = 2 * 3 * 5
  • 60 = 2 * 2 * 3 *5
  • 210 = 2 * 3 * 5 * 7
Testing with other primes between 2 and 9999 and coefficients from 1 to 9999 (trying upper bounds of 999999 seemed to overwhelm the SAGE server) showed the best result was with the unpretentious \( 6 \,n+5 \) that produces a total of 56 primes between \(n=1\) and \(n=100\).

However, this 56% hit rate for primes when n is between 1 and 100 is not sustained. For example, setting lower and upper bounds of 4000 and 5000 for \( 6 \,n+5 \) generates 289 primes between 24005 and 30005. This is an average of 289/1000 or about 28.9%.

on August 30th 2021

See related post titled Linear Prime Chains uploaded on December 21st 2022.

Thursday, 25 October 2018

Self Numbers and Junction Numbers

Today I turned 25407 days old and discovered from Numbers Aplenty that it is a self number or Columbian number. Such a number is defined as one that cannot be written as \(x+\mathrm{sod}(x) \) where \(\mathrm{sod}(\cdot) \) denotes the sum of digits. One is reminded immediately of an inconsummate number that cannot be written as \(x ÷ \mathrm{sod}(x) \) where \(\mathrm{sod}(\cdot) \) denotes the sum of digits. View my blog post about these latter numbers here.

Self numbers are base dependent. From Wikipedia:
In general, for even bases, all odd numbers below the base number are self numbers, since any number below such an odd number would have to also be a 1-digit number which when added to its digit would result in an even number. For odd bases, all odd numbers are self numbers. The set of self numbers in a given base q is infinite and has a positive asymptotic density: when q is odd, this density is 1/2.
D.R.Kaprekar, who introduced these numbers in 1949, gave the following test to determine quickly if a number is self.

Define the functions
\[
\begin{array}{lcl}
d(n)& = & \mathrm{the\ number\ of\ digits\ of\ }n\,,\\[1mm]
r(n)\vphantom{M^{M^M}a_{M_M}}&=& 1+({{(n-1)}\pmod9})\,, \\[1mm]
h(n)&=&\left\{%
\begin{array}{ll}
r(n)/2&\mathrm{\ if\ }r(n)\mathrm{\ is\ even}\,,\\
(r(n)+9)/2&\mathrm{\ if\ }r(n)\mathrm{\ is\ odd}\,.\\
\end{array}\right.\\
\end{array}
\]Then a number \(n\)  is self if, for every \(k=0,1,\dots,d(n)\), it holds
\[
\mathrm{sod}(|n-h(n)-9\cdot k|) \neq h(n)+9\cdot k\,
\]where \(|x|\)  denotes the absolute value of \(x\).

Kaprekar's algorithm of course makes it very easy to write the necessary SAGE code to identify self numbers within a given range of numbers. Here is the code that I developed:


If the SAGE code runs in the SAGE CELL window (sometimes there are glitches), you'll see the output 25407 25418 25420 25431 25442 and so 25418 marks the next occurrence of a self number. The first self numbers (OEIS A003052) are:
1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, 97, 108, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 211, 222, 233, 244, 255, 266, 277, 288, 299, 310, 312, 323, 334, 345, 356, 367, 378, 389, 400, 411, 413, 424, 435, 446, 457, 468, 479, 490, 501, 512, 514, 525
A self prime is a self number that is prime (OEIS A006378). The first few self primes are:
3, 5, 7, 31, 53, 97, 211, 233, 277, 367, 389, 457, 479, 547, 569, 613, 659, 727, 839, 883, 929, 1021, 1087, 1109, 1223, 1289, 1447, 1559, 1627, 1693, 1783, 1873, ... 
Again from Wikipedia: "In October 2006 Luke Pebody demonstrated that the largest known Mersenne prime that is at the same time a self number is \(2^{24036583}−1 \). This is then the largest known self prime as of 2006."

By contrast, a junction number is one that can be written in more than one way as  \(x+\mathrm{sod}(x) \). For example, \(818 \)  is a junction number because it has two generators, \(796 \) and \(805 \). Indeed \[796+7+9+6 = 805+8+0+5 = 818.\]The first junction numbers are:
101, 103, 105, 107, 109, 111, 113, 115, 117, 202, 204, 206, 208, 210, 212, 214, 216, 218, 303, 305, 307, 309, 311, 313, 315, 317, 319, 404, 406, 408, 410, 412, 414, 416, 418, 420, 505, 507
It's easy enough to modify the previous SAGE code so that a list of junction numbers within a given range is generated:


The output generated from this code should be 101 103 105 107 109 111 113 115 117 together with the two smaller numbers that produce them. The junction numbers occur in runs of nine odd numbers and this is clearly seen in Figure 1 that shows the graph of such numbers between 1 and 1000.


Figure 1

Kaprekar's original paper can be viewed here.

Saturday, 20 October 2018

Lotto Simulations

I've written about Lotto before in this post (Oz Lotto) and another (Losing at Lotto). The current post is not about probabilities but simulation. How can we use SageMath to simulate a lottery draw? Well as it turns out it's not too difficult.


The key is to use the ZZ.random_element(lowerbound, upperbound+1) function as in the following code. The trick is not to allow duplicate numbers and that is the reason for the inclusion of Set. This function takes our lotto list which might look like this the list [20, 37, 6, 37, 1, 19, 16] and turns it, after the sort, into the ordered set {1, 6, 16, 19, 20, 37}.

Here is the code I developed. I'm really just a tyro at both Python and SageMath so there may well be much better ways to achieve my goals but this is what I came up with:
# Generate a set of numbers for lotto games
# let N represent how many numbers are required in the game
# let G represent the number of games
# let U represent the upper bound of numbers
G=8
N=7
U=40
for i in range(G):
    lotto=[]
    while len(Set(lotto))<N:
        lotto.append(ZZ.random_element(1,U+1))
    print sorted(Set(lotto))
The following is an example of the output:
[11, 23, 27, 30, 37, 38, 40]
[4, 7, 8, 15, 20, 29, 38]
[8, 9, 13, 14, 21, 28, 36]
[7, 11, 15, 21, 28, 33, 40]
[1, 15, 17, 18, 28, 33, 39]
[4, 7, 11, 14, 18, 29, 32]
[1, 10, 12, 16, 21, 31, 33]
[2, 7, 8, 12, 13, 19, 27]
How really random this output is I don't know. I'm sure SageMath has other ways to generate more truly random numbers but this is sufficient for the modest purposes of the exercise.

The code has the added advantage of being able to accommodate "fixed" numbers. For example, let's say we always want the numbers 23 and 32 included in the output. All that needs to be done is to start with lotto = [23, 32] instead of it being an empty list.

For example:
# Generate a set of numbers for lotto games
# let N represent how many numbers are required in the game
# let G represent the number of games
# let U represent the upper bound of numbers
G=8
N=7
U=40
for i in range(G):
    lotto=[23, 32]
    while len(Set(lotto))<N:
        lotto.append(ZZ.random_element(1,U+1))
    print sorted(Set(lotto))
Here an example of the output:
[10, 11, 21, 23, 32, 35, 37]
[5, 6, 17, 23, 31, 32, 39]
[6, 11, 17, 23, 31, 32, 39]
[3, 15, 18, 23, 26, 30, 32]
[2, 12, 13, 23, 27, 28, 32]
[7, 18, 23, 26, 32, 35, 38]
[2, 11, 17, 19, 23, 32, 33]
[3, 16, 23, 26, 27, 31, 32
Not that I expect it will make any difference to my chances of winning but I'll test this out in some coming Lotto games. Oddly enough what got me thinking about generating some random lotto numbers was this article titled JERRY AND MARGE GO LARGE in the Huffington Post. It's about an American couple who exploited a feature in their state's lottery to make millions of dollars. It's quite an interesting story.

As I've been doing I'll include a SageMathCell with the code so that anyone curious can experiment:

Wednesday, 17 October 2018

Semiprime Chains

Today I turned 25399 days old. This number is a semiprime, meaning that it has two prime factors. In the case of 25399, the prime factors are 11 and 2309. However, the number is a member of OEIS A177216: numbers n that are the product of two distinct primes such that \(2n-1, 4n-3, 8n-7, 16n-15, 32n-31, 64n-63 \text{ and } 128n-127\) are also products of two distinct primes. Below is a screenshot of the mathematical tweet to celebrate the occasion.


Evaluating this leads to the following table:


The chain is thus of the form \(2^a \times n- (2^a-1) \) with the integer \(a \geq 0 \).

The initial members of OEIS A177216 are:
11293, 12139, 25399, 31261, 36199, 44869, 49471, 62521, 72397, 83086, 89737, 91705, 98941, 124846, 125041, 134023, 138994, 144793, 164041, 166171, 170431, 173311, 182527, 199543, 224962, 244294, 258169, 259891, 263086, 275281, 277987 
I was interested to see how many of these terms would survive an extension of the process to \(256 \times n - 255 \), \(512 \times n - 511 \), \(1024 \times n - 1023 \) etc.

Extending the process in the same range to \(256 \times n - 255 \) leads to a considerable thinning of the numbers:
31261 36199 44869 49471 62521 72397 83086 138994 173311 182527 224962 259891 277987
Extending the range to \(512 \times n - 511 \) gives:
31261 36199 138994 173311 259891
Extending the range to \(1024 \times n - 1023 \) gives: 173311

So 173311 is the last man standing. Will it stand any further? As it turns out it will. It holds up to \(2048 \times n - 2047 \) but, at \(4096 \times n - 4095 \), there are three prime factors (419, 601 and 2819) and not two. For \(4096 \times n - 4095 \) to hold, we need to extend the range and this leads to 2212801). Below I've listed the semiprime chain associated with the number 173311.


173311 also has the property that is formed by a concatenation of two primes 173 and 311.

The following SAGE code shows that 2212801 is the only number up to 10 million with a prime chain up to \(4096 \times n - 4095 \):

INPUT

for n in range(1,10000000):
    if len(list(divisors(n)))==4:
        if len(list(divisors(2*n-1)))==4:
            if len(list(divisors(4*n-3)))==4:
                if len(list(divisors(8*n-7)))==4:
                    if len(list(divisors(16*n-15)))==4:
                        if len(list(divisors(32*n-31)))==4:
                            if len(list(divisors(64*n-63)))==4:
                                if len(list(divisors(128*n-127)))==4:
                                    if len(list(divisors(256*n-255)))==4:
                                        if len(list(divisors(512*n-511)))==4:
                                            if len(list(divisors(1024*n-1023)))==4:
                                                if len(list(divisors(2048*n-2047)))==4:
                                                    if len(list(divisors(4096*n-4095)))==4:
                                                        print(n),
OUTPUT

2212801

You can try running the above SAGE code using the evaluate button below the SAGE cell. Sometimes it's a little slow but generally it should work. You can modify the code by adding a # in front of a line e.g. # if len(list(divisors(4096*n-4095)))==4: will remove the 4096 condition and apply only the 2048 and lower conditions. Try it out. You may need to refresh the page after each evaluation.

Tuesday, 16 October 2018

Rhonda Numbers

Today I turned 25398 days old and I made Rhonda numbers the focus of my mathematical tweet of the day:


In base 8, 25398 is represented as 61466 and the product of these base 8 digits is 864. The sum of the prime factors (including multiplicity) of 25398 is 2+3*2+17+83 = 108 and 108 * 8 = 864. It's only the number itself that needs to be changed into a base other than 10. The prime factors and their sum all remain in base 10. So 25398 is a Rhonda number to base 8.

OEIS A100970 lists the initial (base 10) numbers that are Rhonda numbers in base 8 and they are:

1836, 6318, 6622, 10530, 14500, 14739, 17655, 18550, 25398, ...

Numbers Aplenty has this to say about the Rhonda numbers in general:
Rhonda numbers exist only in composite bases. Indeed, the product of the digits of a number in a prime base \(b\) cannot be divisible by \(b\), since every digit is smaller than \(b\). 
Kevin Brown has proved that there are infinite Rhonda numbers. 
The first base-10 Rhonda numbers are 1568, 2835, 4752, 5265, 5439, 5664, 5824, 5832, 8526, 12985, 15625, 15698, 19435, 25284. 
1000 is the smallest Rhonda number in two bases, namely 16 and 36, since: 
\(1000=2^3\cdot 5^3\), \(1000=(3,14,8)_{16}=(27,28)_{36}\) 
\(3\cdot14\cdot8 = 16\cdot(2\cdot3+3\cdot5)\) for base 16   
\(27\cdot28=36\cdot(2\cdot3+3\cdot5)\) for base 36. 
The first smallest Rhonda numbers with respect to one, two, ... , ten bases are 560, 1000, 10200, 5670, 63945, 158400, 322920, 140800, 1200420, 889200.
From MathWorld, the first few Rhonda numbers for small composite bases b are summarised in the following table:

b
OEIS Rhonda numbers
4A10096810206, 11935, 12150, 16031, 45030, 94185, ...
6A100969855, 1029, 3813, 5577, 7040, 7304, 15104, 19136, ...
8A1009701836, 6318, 6622, 10530, 14500, 14739, 17655, 18550, 25398, ...
9A10097315540, 21054, 25331, 44360, 44660, 44733, 47652, ...
10A0995421568, 2835, 4752, 5265, 5439, 5664, 5824, 5832, 8526, 12985, ...
12A100971560, 800, 3993, 4425, 4602, 4888, 7315, 8296, 9315, 11849, 12028, ...
14A10097211475, 18655, 20565, 29631, 31725, 45387, 58404, 58667, 59950, ...
15A1009742392, 2472, 11468, 15873, 17424, 18126, 19152, 20079, 24388, ...
16A1009751000, 1134, 6776, 15912, 19624, 20043, 20355, 23946, 26296, ...

Here is the SageMath code that I developed to generate the sequence in bases from 2 to 36 (with base 16 being used for the example):

b=16 #enter required base
L=[]
for x in range(2,27000):
    d=Integer(x).str(base=b)
    product=1
    for i in range(len(d)):
        product=product*int(d[i], base=b)
    P=list(factor(x))
    sum=0
    for p in P:
        sum+=p[0]*p[1]
    if product/sum ==b and product !=0:
        L.append(x)
print(L)

[1000, 1134, 6776, 15912, 19624, 20043, 20355, 23946, 26296] 

This algorithm will work for all bases from 2 up to 36 but there are no Rhonda numbers in prime bases, so there will be no output for these bases. 

Let's return to what was said in the Numbers Aplenty quote above, viz.:

The first smallest Rhonda numbers that can be written one base only, two bases, three bases etc. are: 

  • one --> 560
  • two --> 1000
  • three --> 10200
  • four --> 5670
  • five --> 63945
  • six --> 158400
  • seven --> 322920
  • eight --> 140800
  • nine --> 1200420
  • ten --> 889200
This site gives 140800 are an example. This is the smallest number that is a Rhonda number in eight different bases. See Figure 1.

Figure 1

Let's use base 198 to illustrate how this works. In base 198, 140800 can be represented as \( (3, 117, 22)_{198} \) and the product of these digits (3, 117 and 22) is 7722. Now 140800 factorises to 2^9 * 5^2 * 11 and the sum of these prime factors is 39 (remember we are working in base 10 here). If we multiply 39 by 198, we get 7722. Thus 140800 is a Rhonda number in base 198 and so it can be shown for the other bases.

on Thursday, April 1st 2021

Friday, 5 October 2018

Duffinian Numbers

Duffinian numbers are defined as numbers that are composite and relatively prime to the sum of their divisors. The first such number is 4 because it is composite and the sum of its divisors (1, 2 and 4) is 7 and relatively prime to 4. The next composite number is 6 whose sum of divisors (1, 2, 3 and 6) is 12. However, since 12 and 6 are not relatively prime it is not Duffinian. The next composite number is 8 with divisors 1, 2, 4 and 8 whose sum is 15 and thus relatively prime to 8. Thus the first two Duffinian numbers are 4 and 8.

The first Duffinian numbers up to 247 are:
4, 8, 9, 16, 21, 25, 27, 32, 35, 36, 39, 49, 50, 55, 57, 63, 64, 65, 75, 77, 81, 85, 93, 98, 100, 111, 115, 119, 121, 125, 128, 129, 133, 143, 144, 155, 161, 169, 171, 175, 183, 185, 187, 189, 201, 203, 205, 209, 215, 217, 219, 221, 225, 235, 237, 242, 243, 245, 247
Since there are 59 numbers listed above, their density is 59/247 or nearly 24%. Thus they are more common than the prime numbers that occur with a frequency of around 18% in the same interval. There is an infinity of such numbers. As explained in Numbers Aplenty:
Any number of the form  \( p^k \)  where  \( p \)  is prime and  \( k \ge 2 \)  is Duffinian, since  \( \sigma(p^k)=1+p+p^2+\cdots+p^k \)  cannot be divisible by \(p \).
Of course, every prime \( p \) is relatively prime to the sum of its divisors \( p+1 \) but by definition the prime numbers are excluded. However, OEIS A014567 lists numbers \(n \) such that \( n \) and \( \sigma(n) \) are relatively prime, without \( n \) needing to be composite. Such numbers are sometimes called sigma primes and of course include all the primes. OEIS A003624 lists the Duffinian numbers.

Numbers Aplenty goes on to say that:
P. Heichelheim proved that there exists a run of five consecutive Duffinian numbers starting at 202605639573839041, and that there cannot exist a longer such run. 
Rose Mary Zbiek has proved that every even Duffinian number is either a square or twice a square. 
The smallest 3 × 3 magic square whose entries are consecutive Duffinian numbers is:
It's a simple enough matter in SAGE to determine whether or not a number is Duffinian. Here is the code (with "gcd" standing for "greatest common divisor"):
number=25387
if gcd(number,sigma(number,1))==1:
    print number, "is Duffinian"
else:
    print number, "is not Duffinian"
The input 25387 produces the output: 25387 is Duffinian

Wednesday, 3 October 2018

Ulam Numbers

I've been encountering these numbers for a while now, ever since making use of the website NUMBERS APLENTY which categorises numbers in a wide variety of ways and one of those categories is that of the Ulam number. Yesterday for example I was 25384 days old and 25384 is an Ulam number defined by the site as:
The Ulam sequence is defined by \(U_1=1, U_2=2 \) and, for \( k>2, U_k \) is the smallest integer that can be written in exactly one way as \(U_i+U_j \) with \( i<j<k \). The members of the Ulam sequence are called Ulam numbers. 
For example, after the first 4 terms which are trivially 1, 2, 3 and 4, the value of \(U_5 \) cannot be 5, since \(5=U_1+U_4=U_2+U_3 \), but it is 6, which can be obtained only as  \( U_2+U_4\)  (not as \(U_3+U_3 \) because the terms added must be distinct).
The problem with the Online Encyclopaedia of Integer Sequences (OEIS) is that it will not flag large numbers like 25384 as Ulam numbers because the numbers in the Ulam sequence (OEIS A002858) are only listed up to 339.
1, 2, 3, 4, 6, 8, 11, 13, 16, 18, 26, 28, 36, 38, 47, 48, 53, 57, 62, 69, 72, 77, 82, 87, 97, 99, 102, 106, 114, 126, 131, 138, 145, 148, 155, 175, 177, 180, 182, 189, 197, 206, 209, 219, 221, 236, 238, 241, 243, 253, 258, 260, 273, 282, 309, 316, 319, 324, 339
There is a list of the first 10,000 Ulam numbers in the links but these numbers do not show up in a search of the OEIS. That's why sites like NUMBERS APLENTY are so useful as a supplement to the OEIS. The site always provides a link to the relevant sequence in the OEIS as well as a Mathworld and Wikipedia link.

So what's special about the Ulam numbers? To begin with they are not distributed uniformly. As the NUMBERS APLENTY website states:
Ulam numbers are not distributed uniformly, but their density has peaks at an average distance of 21.6 (see Figure 1):
A plot of the Ulam numbers up to 1082, arranged line by line in a square 108×108. 
The plot shows the peaks in their density that occur with a frequency roughly equal to 108/5=21.6.
Wikipedia claims that the Ulam numbers have a density of approximately 0.07398 or 7.4%. It also states that:
There are infinitely many Ulam numbers. For, after the first n numbers in the sequence have already been determined, it is always possible to extend the sequence by one more element: \( U_{n − 1} + U_n \) is uniquely represented as a sum of two of the first n numbers, and there may be other smaller numbers that are also uniquely represented in this way, so the next element can be chosen as the smallest of these uniquely representable numbers.
Wikipedia goes on to say that:
The idea can be generalised as (u, v)-Ulam numbers by selecting different starting values (u, v). A sequence of (u, v)-Ulam numbers is regular if the sequence of differences between consecutive numbers in the sequence is eventually periodic. When v is an odd number greater than three, the (2, v)-Ulam numbers are regular. When v is congruent to 1 (mod 4) and at least five, the (4, v)-Ulam numbers are again regular. However, the Ulam numbers themselves do not appear to be regular. 
A sequence of numbers is said to be s-additive if each number in the sequence, after the initial 2s terms of the sequence, has exactly s representations as a sum of two previous numbers. Thus, the Ulam numbers and the (u, v)-Ulam numbers are 1-additive sequences. 
If a sequence is formed by appending the largest number with a unique representation as a sum of two earlier numbers, instead of appending the smallest uniquely representable number, then the resulting sequence is the sequence of Fibonacci numbers. 
This last point about the similarity with the Fibonacci numbers is interesting. Of course the Fibonacci numbers get very big very quickly while the Ulam numbers, because the smallest sum of any two previous numbers is sought, remain relatively smaller.

 Mathworld has a table of some of the other Ulam sequences:


I was struggling to get my SAGE code to generate these sequences of terms but came across some Python 2 code (source) that does the job, although I'm struggling to understand how it works:
ulams=[ ]
ulams.append(1)
ulams.append(2)
limit=100
sums=[0 for i in range(2*limit)]
newUlam=2
sumIndex=1
while(newUlam <limit):
  for i in ulams:
if (i<newUlam):
sums[i+newUlam] += 1
while(sums[sumIndex]!=1):
sumIndex += 1
newUlam = sumIndex
sumIndex += 1
ulams.append(newUlam) for i in ulams:
print i
With the limit set to 100, the following output is produced: 1 2 3 4 6 8 11 13 16 18 26 28 36 38 47 48 53 57 62 69 72 77 82 87 97 99 102

The code can be easily modified to generate other sequences with different starting terms e.g. 2 and 3:
ulams=[ ]
ulams.append(2)
ulams.append(3)
limit=100
sums=[0 for i in range(2*limit)]
newUlam=3
sumIndex=1
while(newUlam <limit):
  for i in ulams:
if (i<newUlam):
sums[i+newUlam] += 1
while(sums[sumIndex]!=1):
sumIndex += 1
newUlam = sumIndex
sumIndex += 1
ulams.append(newUlam) for i in ulams:
print i
This code produces the output: 2 3 5 7 8 9 13 14 18 19 24 25 29 30 35 36 40 41 46 51 56 63 68 72 73 78 79 83 84 89 94 115

ADDENDUM: I finally developed my own code which I do understand and it works! Here are the terms below 200 in the Ulam sequence beginning 2,3:
ulam=[i for i in range(1,200)]
ulam[0], ulam[1]=2,3
k=2
while k<len(ulam):
    count=0
    for x in range(k):
        for y in range(k):
            if ulam[x] > ulam[y]:
                if ulam[x] + ulam[y] == ulam[k]:
                    count+=1
    if count!=1:
        ulam.remove(ulam[k])
        k-=1
    k+=1
print ulam  
This code produces the output: 2, 3, 5, 7, 8, 9, 13, 14, 18, 19, 24, 25, 29, 30, 35, 36, 40, 41, 46, 51, 56, 63, 68, 72, 73, 78, 79, 83, 84, 89, 94, 115, 117, 126, 153, 160, 165, 169, 170, 175, 176, 181, 186, 191

Here is a link to an interesting article that looks at patterns in these 1-additive sequences.