Using the recursion theorem to implement the Sieve of Eratosthenes.
Update: I provided an answer here that shows how to define a mathematical function using the recursion theorem. This function can be reconfigured to compute the prime-counting function, $pi(x)$.
Only one question remains:
Question 1: Has the Sieve of Eratosthenes already been mathematically
revamped as a recursive function?
I did not find the word 'recursion' in the wikipedia article Generating primes, so this theory might be useful.
When running computers to get a list of all primes numbers using recursion, the 'state variables' should be retained for the next computer run.
The initial development was the construction of a Python program that maintained/updated state variables to generate, and keep generating, the list of prime numbers. I was using concepts found in the wiki article The Sieve of Eratosthenes.
elementary-number-theory prime-numbers computer-science recursion
add a comment |
Update: I provided an answer here that shows how to define a mathematical function using the recursion theorem. This function can be reconfigured to compute the prime-counting function, $pi(x)$.
Only one question remains:
Question 1: Has the Sieve of Eratosthenes already been mathematically
revamped as a recursive function?
I did not find the word 'recursion' in the wikipedia article Generating primes, so this theory might be useful.
When running computers to get a list of all primes numbers using recursion, the 'state variables' should be retained for the next computer run.
The initial development was the construction of a Python program that maintained/updated state variables to generate, and keep generating, the list of prime numbers. I was using concepts found in the wiki article The Sieve of Eratosthenes.
elementary-number-theory prime-numbers computer-science recursion
1
Why do you think, that the function in your (put-on-hold) question is recursive?
– gammatester
Nov 14 '18 at 12:08
@gammatester The python program has state variables that change which each new input. The function $tau$ needs more than one variable to run.
– CopyPasteIt
Nov 14 '18 at 12:13
You are aware that multiplication can be defined recursively, hence forbidding it makes no sense?
– Hagen von Eitzen
Nov 14 '18 at 12:18
$tau(n)=Gamma(n,2,2)$ with $$Gamma(a,b,c)=begin{cases}1&a=b\0&c=a>b\Gamma(a,b+1,b+1)&c>a>b\Gamma(a,b,b+c)&text{otherwise} end{cases}$$
– Hagen von Eitzen
Nov 14 '18 at 12:23
add a comment |
Update: I provided an answer here that shows how to define a mathematical function using the recursion theorem. This function can be reconfigured to compute the prime-counting function, $pi(x)$.
Only one question remains:
Question 1: Has the Sieve of Eratosthenes already been mathematically
revamped as a recursive function?
I did not find the word 'recursion' in the wikipedia article Generating primes, so this theory might be useful.
When running computers to get a list of all primes numbers using recursion, the 'state variables' should be retained for the next computer run.
The initial development was the construction of a Python program that maintained/updated state variables to generate, and keep generating, the list of prime numbers. I was using concepts found in the wiki article The Sieve of Eratosthenes.
elementary-number-theory prime-numbers computer-science recursion
Update: I provided an answer here that shows how to define a mathematical function using the recursion theorem. This function can be reconfigured to compute the prime-counting function, $pi(x)$.
Only one question remains:
Question 1: Has the Sieve of Eratosthenes already been mathematically
revamped as a recursive function?
I did not find the word 'recursion' in the wikipedia article Generating primes, so this theory might be useful.
When running computers to get a list of all primes numbers using recursion, the 'state variables' should be retained for the next computer run.
The initial development was the construction of a Python program that maintained/updated state variables to generate, and keep generating, the list of prime numbers. I was using concepts found in the wiki article The Sieve of Eratosthenes.
elementary-number-theory prime-numbers computer-science recursion
elementary-number-theory prime-numbers computer-science recursion
edited Nov 16 '18 at 13:54
CopyPasteIt
asked Nov 14 '18 at 12:03
CopyPasteItCopyPasteIt
4,0651627
4,0651627
1
Why do you think, that the function in your (put-on-hold) question is recursive?
– gammatester
Nov 14 '18 at 12:08
@gammatester The python program has state variables that change which each new input. The function $tau$ needs more than one variable to run.
– CopyPasteIt
Nov 14 '18 at 12:13
You are aware that multiplication can be defined recursively, hence forbidding it makes no sense?
– Hagen von Eitzen
Nov 14 '18 at 12:18
$tau(n)=Gamma(n,2,2)$ with $$Gamma(a,b,c)=begin{cases}1&a=b\0&c=a>b\Gamma(a,b+1,b+1)&c>a>b\Gamma(a,b,b+c)&text{otherwise} end{cases}$$
– Hagen von Eitzen
Nov 14 '18 at 12:23
add a comment |
1
Why do you think, that the function in your (put-on-hold) question is recursive?
– gammatester
Nov 14 '18 at 12:08
@gammatester The python program has state variables that change which each new input. The function $tau$ needs more than one variable to run.
– CopyPasteIt
Nov 14 '18 at 12:13
You are aware that multiplication can be defined recursively, hence forbidding it makes no sense?
– Hagen von Eitzen
Nov 14 '18 at 12:18
$tau(n)=Gamma(n,2,2)$ with $$Gamma(a,b,c)=begin{cases}1&a=b\0&c=a>b\Gamma(a,b+1,b+1)&c>a>b\Gamma(a,b,b+c)&text{otherwise} end{cases}$$
– Hagen von Eitzen
Nov 14 '18 at 12:23
1
1
Why do you think, that the function in your (put-on-hold) question is recursive?
– gammatester
Nov 14 '18 at 12:08
Why do you think, that the function in your (put-on-hold) question is recursive?
– gammatester
Nov 14 '18 at 12:08
@gammatester The python program has state variables that change which each new input. The function $tau$ needs more than one variable to run.
– CopyPasteIt
Nov 14 '18 at 12:13
@gammatester The python program has state variables that change which each new input. The function $tau$ needs more than one variable to run.
– CopyPasteIt
Nov 14 '18 at 12:13
You are aware that multiplication can be defined recursively, hence forbidding it makes no sense?
– Hagen von Eitzen
Nov 14 '18 at 12:18
You are aware that multiplication can be defined recursively, hence forbidding it makes no sense?
– Hagen von Eitzen
Nov 14 '18 at 12:18
$tau(n)=Gamma(n,2,2)$ with $$Gamma(a,b,c)=begin{cases}1&a=b\0&c=a>b\Gamma(a,b+1,b+1)&c>a>b\Gamma(a,b,b+c)&text{otherwise} end{cases}$$
– Hagen von Eitzen
Nov 14 '18 at 12:23
$tau(n)=Gamma(n,2,2)$ with $$Gamma(a,b,c)=begin{cases}1&a=b\0&c=a>b\Gamma(a,b+1,b+1)&c>a>b\Gamma(a,b,b+c)&text{otherwise} end{cases}$$
– Hagen von Eitzen
Nov 14 '18 at 12:23
add a comment |
2 Answers
2
active
oldest
votes
The Legendre formula,
https://en.wikipedia.org/wiki/Prime-counting_function#Algorithms_for_evaluating_π(x)
http://mathworld.wolfram.com/LegendresFormula.html
which based on the sieve, is recursive: $phi(x,a)=phi(x,a-1)-phi(frac{x}{p_a},a-1)$. With it you can find $pi(x)=phi(x,a)+a-1$ where $a=pi(sqrt[2]{x})$.
However, I am not sure it is recursive the way you want it to be recursive
Interestingly, the python update is looking more mathematical - using sets! The function $Gamma(n)$ is 'carrying' the set of all primes less than or equal to $n$ as the first coordinate of a changing relation in $mathbb N times mathbb N$. see math.stackexchange.com/questions/2997737/…
– CopyPasteIt
Nov 14 '18 at 18:38
add a comment |
Here $mathbb N = {2,3,4,dots}$.
Let $mathcal P$ denote the set of all finite subsets of $mathbb N times mathbb N$.
We define
$tag 1 gamma_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(n,n+n)}$
We define
$tag 2 mu_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(m,n+m) ; | ; (m,n) in rho }$
The mapping $Gamma: mathbb N times mathcal P to mathcal P$ is defined by
$$
Gamma(n,rho) = left{begin{array}{lr}
gamma_n(rho), & text{when } n notin text{Range}(rho)\
mu_n(rho), & text{otherwise}
end{array}right}
$$
Using the recursion theorem, we define
$tag 3 mathtt E: mathbb N cup {1} to mathcal P quad quad text{ by }$
$quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(1) = emptyset$
$quadquad quadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(n+1) = Gamma(n+1,mathtt E(n))$
The function $mathtt E$ has the property that the projection of $mathtt E(n)$ onto the first coordinate is the set of all prime numbers less than or equal to $n$. So, letting $pr_1$ denote this projection, we define
$tag 4 pi': mathbb N to mathbb N$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; n mapsto text{#} left[, pr_1(mathtt E(n)),right]$
so that $pi'(n)$ is the set of all primes less than or equal to $n$. It is immediate that this function is the restriction of the prime-counting function $pi$ to $mathbb N$.
Values of $mathtt E(n)$ for $n le 11:$
E(2) = {(2, 4)}
E(3) = {(2, 4), (3, 6)}
E(4) = {(2, 6), (2, 4), (3, 6)}
E(5) = {(2, 6), (5, 10), (2, 4), (3, 6)}
E(6) = {(2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(7) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(8) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4), (2, 10)}
E(9) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (3, 12), (2, 8), (2, 4), (2, 10)}
E(10) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
E(11) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (11, 22), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
Note: These function values came from the Python program. Since mathematics is not concerned with 'efficiency' in any way, the program was 'dumbed down' so the outputs of $mathtt E$ can contain elements that are no longer used by the recursion algorithm; this made it easier to define the algorithm.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2998187%2fusing-the-recursion-theorem-to-implement-the-sieve-of-eratosthenes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The Legendre formula,
https://en.wikipedia.org/wiki/Prime-counting_function#Algorithms_for_evaluating_π(x)
http://mathworld.wolfram.com/LegendresFormula.html
which based on the sieve, is recursive: $phi(x,a)=phi(x,a-1)-phi(frac{x}{p_a},a-1)$. With it you can find $pi(x)=phi(x,a)+a-1$ where $a=pi(sqrt[2]{x})$.
However, I am not sure it is recursive the way you want it to be recursive
Interestingly, the python update is looking more mathematical - using sets! The function $Gamma(n)$ is 'carrying' the set of all primes less than or equal to $n$ as the first coordinate of a changing relation in $mathbb N times mathbb N$. see math.stackexchange.com/questions/2997737/…
– CopyPasteIt
Nov 14 '18 at 18:38
add a comment |
The Legendre formula,
https://en.wikipedia.org/wiki/Prime-counting_function#Algorithms_for_evaluating_π(x)
http://mathworld.wolfram.com/LegendresFormula.html
which based on the sieve, is recursive: $phi(x,a)=phi(x,a-1)-phi(frac{x}{p_a},a-1)$. With it you can find $pi(x)=phi(x,a)+a-1$ where $a=pi(sqrt[2]{x})$.
However, I am not sure it is recursive the way you want it to be recursive
Interestingly, the python update is looking more mathematical - using sets! The function $Gamma(n)$ is 'carrying' the set of all primes less than or equal to $n$ as the first coordinate of a changing relation in $mathbb N times mathbb N$. see math.stackexchange.com/questions/2997737/…
– CopyPasteIt
Nov 14 '18 at 18:38
add a comment |
The Legendre formula,
https://en.wikipedia.org/wiki/Prime-counting_function#Algorithms_for_evaluating_π(x)
http://mathworld.wolfram.com/LegendresFormula.html
which based on the sieve, is recursive: $phi(x,a)=phi(x,a-1)-phi(frac{x}{p_a},a-1)$. With it you can find $pi(x)=phi(x,a)+a-1$ where $a=pi(sqrt[2]{x})$.
However, I am not sure it is recursive the way you want it to be recursive
The Legendre formula,
https://en.wikipedia.org/wiki/Prime-counting_function#Algorithms_for_evaluating_π(x)
http://mathworld.wolfram.com/LegendresFormula.html
which based on the sieve, is recursive: $phi(x,a)=phi(x,a-1)-phi(frac{x}{p_a},a-1)$. With it you can find $pi(x)=phi(x,a)+a-1$ where $a=pi(sqrt[2]{x})$.
However, I am not sure it is recursive the way you want it to be recursive
answered Nov 14 '18 at 18:17
Collag3nCollag3n
669211
669211
Interestingly, the python update is looking more mathematical - using sets! The function $Gamma(n)$ is 'carrying' the set of all primes less than or equal to $n$ as the first coordinate of a changing relation in $mathbb N times mathbb N$. see math.stackexchange.com/questions/2997737/…
– CopyPasteIt
Nov 14 '18 at 18:38
add a comment |
Interestingly, the python update is looking more mathematical - using sets! The function $Gamma(n)$ is 'carrying' the set of all primes less than or equal to $n$ as the first coordinate of a changing relation in $mathbb N times mathbb N$. see math.stackexchange.com/questions/2997737/…
– CopyPasteIt
Nov 14 '18 at 18:38
Interestingly, the python update is looking more mathematical - using sets! The function $Gamma(n)$ is 'carrying' the set of all primes less than or equal to $n$ as the first coordinate of a changing relation in $mathbb N times mathbb N$. see math.stackexchange.com/questions/2997737/…
– CopyPasteIt
Nov 14 '18 at 18:38
Interestingly, the python update is looking more mathematical - using sets! The function $Gamma(n)$ is 'carrying' the set of all primes less than or equal to $n$ as the first coordinate of a changing relation in $mathbb N times mathbb N$. see math.stackexchange.com/questions/2997737/…
– CopyPasteIt
Nov 14 '18 at 18:38
add a comment |
Here $mathbb N = {2,3,4,dots}$.
Let $mathcal P$ denote the set of all finite subsets of $mathbb N times mathbb N$.
We define
$tag 1 gamma_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(n,n+n)}$
We define
$tag 2 mu_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(m,n+m) ; | ; (m,n) in rho }$
The mapping $Gamma: mathbb N times mathcal P to mathcal P$ is defined by
$$
Gamma(n,rho) = left{begin{array}{lr}
gamma_n(rho), & text{when } n notin text{Range}(rho)\
mu_n(rho), & text{otherwise}
end{array}right}
$$
Using the recursion theorem, we define
$tag 3 mathtt E: mathbb N cup {1} to mathcal P quad quad text{ by }$
$quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(1) = emptyset$
$quadquad quadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(n+1) = Gamma(n+1,mathtt E(n))$
The function $mathtt E$ has the property that the projection of $mathtt E(n)$ onto the first coordinate is the set of all prime numbers less than or equal to $n$. So, letting $pr_1$ denote this projection, we define
$tag 4 pi': mathbb N to mathbb N$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; n mapsto text{#} left[, pr_1(mathtt E(n)),right]$
so that $pi'(n)$ is the set of all primes less than or equal to $n$. It is immediate that this function is the restriction of the prime-counting function $pi$ to $mathbb N$.
Values of $mathtt E(n)$ for $n le 11:$
E(2) = {(2, 4)}
E(3) = {(2, 4), (3, 6)}
E(4) = {(2, 6), (2, 4), (3, 6)}
E(5) = {(2, 6), (5, 10), (2, 4), (3, 6)}
E(6) = {(2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(7) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(8) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4), (2, 10)}
E(9) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (3, 12), (2, 8), (2, 4), (2, 10)}
E(10) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
E(11) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (11, 22), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
Note: These function values came from the Python program. Since mathematics is not concerned with 'efficiency' in any way, the program was 'dumbed down' so the outputs of $mathtt E$ can contain elements that are no longer used by the recursion algorithm; this made it easier to define the algorithm.
add a comment |
Here $mathbb N = {2,3,4,dots}$.
Let $mathcal P$ denote the set of all finite subsets of $mathbb N times mathbb N$.
We define
$tag 1 gamma_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(n,n+n)}$
We define
$tag 2 mu_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(m,n+m) ; | ; (m,n) in rho }$
The mapping $Gamma: mathbb N times mathcal P to mathcal P$ is defined by
$$
Gamma(n,rho) = left{begin{array}{lr}
gamma_n(rho), & text{when } n notin text{Range}(rho)\
mu_n(rho), & text{otherwise}
end{array}right}
$$
Using the recursion theorem, we define
$tag 3 mathtt E: mathbb N cup {1} to mathcal P quad quad text{ by }$
$quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(1) = emptyset$
$quadquad quadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(n+1) = Gamma(n+1,mathtt E(n))$
The function $mathtt E$ has the property that the projection of $mathtt E(n)$ onto the first coordinate is the set of all prime numbers less than or equal to $n$. So, letting $pr_1$ denote this projection, we define
$tag 4 pi': mathbb N to mathbb N$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; n mapsto text{#} left[, pr_1(mathtt E(n)),right]$
so that $pi'(n)$ is the set of all primes less than or equal to $n$. It is immediate that this function is the restriction of the prime-counting function $pi$ to $mathbb N$.
Values of $mathtt E(n)$ for $n le 11:$
E(2) = {(2, 4)}
E(3) = {(2, 4), (3, 6)}
E(4) = {(2, 6), (2, 4), (3, 6)}
E(5) = {(2, 6), (5, 10), (2, 4), (3, 6)}
E(6) = {(2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(7) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(8) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4), (2, 10)}
E(9) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (3, 12), (2, 8), (2, 4), (2, 10)}
E(10) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
E(11) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (11, 22), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
Note: These function values came from the Python program. Since mathematics is not concerned with 'efficiency' in any way, the program was 'dumbed down' so the outputs of $mathtt E$ can contain elements that are no longer used by the recursion algorithm; this made it easier to define the algorithm.
add a comment |
Here $mathbb N = {2,3,4,dots}$.
Let $mathcal P$ denote the set of all finite subsets of $mathbb N times mathbb N$.
We define
$tag 1 gamma_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(n,n+n)}$
We define
$tag 2 mu_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(m,n+m) ; | ; (m,n) in rho }$
The mapping $Gamma: mathbb N times mathcal P to mathcal P$ is defined by
$$
Gamma(n,rho) = left{begin{array}{lr}
gamma_n(rho), & text{when } n notin text{Range}(rho)\
mu_n(rho), & text{otherwise}
end{array}right}
$$
Using the recursion theorem, we define
$tag 3 mathtt E: mathbb N cup {1} to mathcal P quad quad text{ by }$
$quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(1) = emptyset$
$quadquad quadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(n+1) = Gamma(n+1,mathtt E(n))$
The function $mathtt E$ has the property that the projection of $mathtt E(n)$ onto the first coordinate is the set of all prime numbers less than or equal to $n$. So, letting $pr_1$ denote this projection, we define
$tag 4 pi': mathbb N to mathbb N$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; n mapsto text{#} left[, pr_1(mathtt E(n)),right]$
so that $pi'(n)$ is the set of all primes less than or equal to $n$. It is immediate that this function is the restriction of the prime-counting function $pi$ to $mathbb N$.
Values of $mathtt E(n)$ for $n le 11:$
E(2) = {(2, 4)}
E(3) = {(2, 4), (3, 6)}
E(4) = {(2, 6), (2, 4), (3, 6)}
E(5) = {(2, 6), (5, 10), (2, 4), (3, 6)}
E(6) = {(2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(7) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(8) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4), (2, 10)}
E(9) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (3, 12), (2, 8), (2, 4), (2, 10)}
E(10) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
E(11) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (11, 22), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
Note: These function values came from the Python program. Since mathematics is not concerned with 'efficiency' in any way, the program was 'dumbed down' so the outputs of $mathtt E$ can contain elements that are no longer used by the recursion algorithm; this made it easier to define the algorithm.
Here $mathbb N = {2,3,4,dots}$.
Let $mathcal P$ denote the set of all finite subsets of $mathbb N times mathbb N$.
We define
$tag 1 gamma_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(n,n+n)}$
We define
$tag 2 mu_n: mathcal P to mathcal P$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; rho mapsto rho cup {(m,n+m) ; | ; (m,n) in rho }$
The mapping $Gamma: mathbb N times mathcal P to mathcal P$ is defined by
$$
Gamma(n,rho) = left{begin{array}{lr}
gamma_n(rho), & text{when } n notin text{Range}(rho)\
mu_n(rho), & text{otherwise}
end{array}right}
$$
Using the recursion theorem, we define
$tag 3 mathtt E: mathbb N cup {1} to mathcal P quad quad text{ by }$
$quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(1) = emptyset$
$quadquad quadquadquadquadquadquadquadquadquadquadquadquadquadquad mathtt E(n+1) = Gamma(n+1,mathtt E(n))$
The function $mathtt E$ has the property that the projection of $mathtt E(n)$ onto the first coordinate is the set of all prime numbers less than or equal to $n$. So, letting $pr_1$ denote this projection, we define
$tag 4 pi': mathbb N to mathbb N$
$quad quadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquadquad;;; n mapsto text{#} left[, pr_1(mathtt E(n)),right]$
so that $pi'(n)$ is the set of all primes less than or equal to $n$. It is immediate that this function is the restriction of the prime-counting function $pi$ to $mathbb N$.
Values of $mathtt E(n)$ for $n le 11:$
E(2) = {(2, 4)}
E(3) = {(2, 4), (3, 6)}
E(4) = {(2, 6), (2, 4), (3, 6)}
E(5) = {(2, 6), (5, 10), (2, 4), (3, 6)}
E(6) = {(2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(7) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4)}
E(8) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (2, 8), (2, 4), (2, 10)}
E(9) = {(7, 14), (2, 6), (5, 10), (3, 9), (3, 6), (3, 12), (2, 8), (2, 4), (2, 10)}
E(10) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
E(11) = {(7, 14), (2, 6), (5, 10), (3, 12), (2, 8), (11, 22), (2, 10), (3, 9), (5, 15), (2, 12), (3, 6), (2, 4)}
Note: These function values came from the Python program. Since mathematics is not concerned with 'efficiency' in any way, the program was 'dumbed down' so the outputs of $mathtt E$ can contain elements that are no longer used by the recursion algorithm; this made it easier to define the algorithm.
edited Nov 16 '18 at 14:07
answered Nov 15 '18 at 0:41
CopyPasteItCopyPasteIt
4,0651627
4,0651627
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2998187%2fusing-the-recursion-theorem-to-implement-the-sieve-of-eratosthenes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Why do you think, that the function in your (put-on-hold) question is recursive?
– gammatester
Nov 14 '18 at 12:08
@gammatester The python program has state variables that change which each new input. The function $tau$ needs more than one variable to run.
– CopyPasteIt
Nov 14 '18 at 12:13
You are aware that multiplication can be defined recursively, hence forbidding it makes no sense?
– Hagen von Eitzen
Nov 14 '18 at 12:18
$tau(n)=Gamma(n,2,2)$ with $$Gamma(a,b,c)=begin{cases}1&a=b\0&c=a>b\Gamma(a,b+1,b+1)&c>a>b\Gamma(a,b,b+c)&text{otherwise} end{cases}$$
– Hagen von Eitzen
Nov 14 '18 at 12:23