Skip to main content
Commonmark migration
Source Link

Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not in the list. So the assumption that only finitely primes exist is false.

Now let's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

Challenge

###Challenge GivenGiven a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 

Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not in the list. So the assumption that only finitely primes exist is false.

Now let's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

###Challenge Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 

Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not in the list. So the assumption that only finitely primes exist is false.

Now let's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

Challenge

Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 
Notice removed Reward existing answer by Adám
Bounty Ended with Sherlock9's answer chosen by Adám
Notice added Reward existing answer by Adám
Bounty Started worth 100 reputation by Adám
Tweeted twitter.com/StackCodeGolf/status/1169852740404514817
grammar corrections
Source Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 697

Since Euclid, we knowhave known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not in the list. So the assumption that only finitely primes exist is false.

Now let's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

###Challenge Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 

Since Euclid, we know that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not in the list. So the assumption that only finitely primes exist is false.

Now let's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

###Challenge Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 

Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not in the list. So the assumption that only finitely primes exist is false.

Now let's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

###Challenge Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 

Infinitely many Primesprimes

Since Euclid, we know that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, letslet's say \$p_1,p_2,...,p_n\$. Then, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so it'sits prime factorization must yield a new prime that was not in the list yet. So the assumption that only finitely primes exist, is false.

Now letslet's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

###Challenge Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 

Infinitely many Primes

Since Euclid we know that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, lets say \$p_1,p_2,...,p_n\$. Then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so it's prime factorization must yield a new prime that was not in the list yet. So the assumption that only finitely primes exist, is false.

Now lets assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$ so both \$13\$ and \$139\$ are new primes, etc. In the case we get a composite number, we just take the least new prime. This results in A000945.

###Challenge Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 

Infinitely many primes

Since Euclid, we know that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not in the list. So the assumption that only finitely primes exist is false.

Now let's assume that \$2\$ is the only prime. The method from above yields \$2+1=3\$ as a new (possible) prime. Applying the method again yields \$2\cdot 3+1=7\$, and then \$2\cdot 3\cdot 7+1=43\$, then \$2\cdot 3\cdot 7\cdot 43+1=13\cdot 139\$, so both \$13\$ and \$139\$ are new primes, etc. In the case where we get a composite number, we just take the least new prime. This results in A000945.

###Challenge Given a prime \$p_1\$ and an integer \$n\$ calculate the \$n\$-th term \$p_n\$ of the sequence defined as follows:

$$p_n := \min(\operatorname{primefactors}(p_1\cdot p_2\cdot ... \cdot p_{n-1} + 1))$$

These sequences are known as Euclid-Mullin-sequences.

###Examples

For \$p_1 = 2\$:

1 2 2 3 3 7 4 43 5 13 6 53 7 5 8 6221671 9 38709183810571 

For \$p_1 = 5\$ (A051308):

1 5 2 2 3 11 4 3 5 331 6 19 7 199 8 53 9 21888927391 

For \$p_1 = 97\$ (A051330)

1 97 2 2 3 3 4 11 5 19 6 7 7 461 8 719 9 5 
Became Hot Network Question
I think that was an error
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221
Loading
deleted 4 characters in body
Source Link
flawr
  • 44.1k
  • 7
  • 109
  • 253
Loading
added 214 characters in body
Source Link
flawr
  • 44.1k
  • 7
  • 109
  • 253
Loading
Source Link
flawr
  • 44.1k
  • 7
  • 109
  • 253
Loading