Find formula for function of $n$ returning $0$ if $n$ is composite and $1$ if $n$ is prime












7














Sample problem:




Find an equation $theta(n)$ for which $theta(n)=left{ begin{array} &0, text{when } nin text{Composed} \ n, text{when } nin text{Prime} end{array} right.$




This problem is from the International Youth Math Challenge $2018$ and since they do not return marked sheets, I am unsure if my solution was correct.



My final answer was: $$theta (n)=n-ncdot text{sgn} left(prod_{i=1}^{infty} |n-p_i|right)$$ where $p_i$ is the $i^{text{th}}$ prime number. This is all I could come up with and to be honest, I am not too happy with it, because I feel like I have basically chosen something that will only give the answer I want. Is this solution correct, mathematically? Is there a better solution?



Note: $text {sgn}(n)$ is the $text{sign}$ or $text{signum}$ function and $$text{sgn}(n)=left{ begin{array} &-1; nlt 0\ 0; n=0\ 1; ngt 0 end{array} right.$$










share|cite|improve this question
























  • Are you sure you're giving the complete statement of the problem? I don't think it makes sense without some sort of restriction as to what kind of functions/primitives you are allowed to use in a solution.
    – Evangelos Bampas
    Dec 21 at 10:20










  • The infinite product formula you suggest requires to compute an infinite product, which cannot be done in practice (and to define the signum function at $+infty$, which is not so usual), and to know the full set of primes, which seems rather impractical as well. Easy remedies to these two defects are suggested below.
    – Did
    Dec 21 at 10:59












  • @Did which is what my title wonders. I only get the results I want, I cannot make further assumptions.
    – Mohammad Zuhair Khan
    Dec 21 at 15:33
















7














Sample problem:




Find an equation $theta(n)$ for which $theta(n)=left{ begin{array} &0, text{when } nin text{Composed} \ n, text{when } nin text{Prime} end{array} right.$




This problem is from the International Youth Math Challenge $2018$ and since they do not return marked sheets, I am unsure if my solution was correct.



My final answer was: $$theta (n)=n-ncdot text{sgn} left(prod_{i=1}^{infty} |n-p_i|right)$$ where $p_i$ is the $i^{text{th}}$ prime number. This is all I could come up with and to be honest, I am not too happy with it, because I feel like I have basically chosen something that will only give the answer I want. Is this solution correct, mathematically? Is there a better solution?



Note: $text {sgn}(n)$ is the $text{sign}$ or $text{signum}$ function and $$text{sgn}(n)=left{ begin{array} &-1; nlt 0\ 0; n=0\ 1; ngt 0 end{array} right.$$










share|cite|improve this question
























  • Are you sure you're giving the complete statement of the problem? I don't think it makes sense without some sort of restriction as to what kind of functions/primitives you are allowed to use in a solution.
    – Evangelos Bampas
    Dec 21 at 10:20










  • The infinite product formula you suggest requires to compute an infinite product, which cannot be done in practice (and to define the signum function at $+infty$, which is not so usual), and to know the full set of primes, which seems rather impractical as well. Easy remedies to these two defects are suggested below.
    – Did
    Dec 21 at 10:59












  • @Did which is what my title wonders. I only get the results I want, I cannot make further assumptions.
    – Mohammad Zuhair Khan
    Dec 21 at 15:33














7












7








7


3





Sample problem:




Find an equation $theta(n)$ for which $theta(n)=left{ begin{array} &0, text{when } nin text{Composed} \ n, text{when } nin text{Prime} end{array} right.$




This problem is from the International Youth Math Challenge $2018$ and since they do not return marked sheets, I am unsure if my solution was correct.



My final answer was: $$theta (n)=n-ncdot text{sgn} left(prod_{i=1}^{infty} |n-p_i|right)$$ where $p_i$ is the $i^{text{th}}$ prime number. This is all I could come up with and to be honest, I am not too happy with it, because I feel like I have basically chosen something that will only give the answer I want. Is this solution correct, mathematically? Is there a better solution?



Note: $text {sgn}(n)$ is the $text{sign}$ or $text{signum}$ function and $$text{sgn}(n)=left{ begin{array} &-1; nlt 0\ 0; n=0\ 1; ngt 0 end{array} right.$$










share|cite|improve this question















Sample problem:




Find an equation $theta(n)$ for which $theta(n)=left{ begin{array} &0, text{when } nin text{Composed} \ n, text{when } nin text{Prime} end{array} right.$




This problem is from the International Youth Math Challenge $2018$ and since they do not return marked sheets, I am unsure if my solution was correct.



My final answer was: $$theta (n)=n-ncdot text{sgn} left(prod_{i=1}^{infty} |n-p_i|right)$$ where $p_i$ is the $i^{text{th}}$ prime number. This is all I could come up with and to be honest, I am not too happy with it, because I feel like I have basically chosen something that will only give the answer I want. Is this solution correct, mathematically? Is there a better solution?



Note: $text {sgn}(n)$ is the $text{sign}$ or $text{signum}$ function and $$text{sgn}(n)=left{ begin{array} &-1; nlt 0\ 0; n=0\ 1; ngt 0 end{array} right.$$







prime-numbers contest-math






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 21 at 11:02









Did

246k23220454




246k23220454










asked Dec 21 at 5:50









Mohammad Zuhair Khan

1,4452525




1,4452525












  • Are you sure you're giving the complete statement of the problem? I don't think it makes sense without some sort of restriction as to what kind of functions/primitives you are allowed to use in a solution.
    – Evangelos Bampas
    Dec 21 at 10:20










  • The infinite product formula you suggest requires to compute an infinite product, which cannot be done in practice (and to define the signum function at $+infty$, which is not so usual), and to know the full set of primes, which seems rather impractical as well. Easy remedies to these two defects are suggested below.
    – Did
    Dec 21 at 10:59












  • @Did which is what my title wonders. I only get the results I want, I cannot make further assumptions.
    – Mohammad Zuhair Khan
    Dec 21 at 15:33


















  • Are you sure you're giving the complete statement of the problem? I don't think it makes sense without some sort of restriction as to what kind of functions/primitives you are allowed to use in a solution.
    – Evangelos Bampas
    Dec 21 at 10:20










  • The infinite product formula you suggest requires to compute an infinite product, which cannot be done in practice (and to define the signum function at $+infty$, which is not so usual), and to know the full set of primes, which seems rather impractical as well. Easy remedies to these two defects are suggested below.
    – Did
    Dec 21 at 10:59












  • @Did which is what my title wonders. I only get the results I want, I cannot make further assumptions.
    – Mohammad Zuhair Khan
    Dec 21 at 15:33
















Are you sure you're giving the complete statement of the problem? I don't think it makes sense without some sort of restriction as to what kind of functions/primitives you are allowed to use in a solution.
– Evangelos Bampas
Dec 21 at 10:20




Are you sure you're giving the complete statement of the problem? I don't think it makes sense without some sort of restriction as to what kind of functions/primitives you are allowed to use in a solution.
– Evangelos Bampas
Dec 21 at 10:20












The infinite product formula you suggest requires to compute an infinite product, which cannot be done in practice (and to define the signum function at $+infty$, which is not so usual), and to know the full set of primes, which seems rather impractical as well. Easy remedies to these two defects are suggested below.
– Did
Dec 21 at 10:59






The infinite product formula you suggest requires to compute an infinite product, which cannot be done in practice (and to define the signum function at $+infty$, which is not so usual), and to know the full set of primes, which seems rather impractical as well. Easy remedies to these two defects are suggested below.
– Did
Dec 21 at 10:59














@Did which is what my title wonders. I only get the results I want, I cannot make further assumptions.
– Mohammad Zuhair Khan
Dec 21 at 15:33




@Did which is what my title wonders. I only get the results I want, I cannot make further assumptions.
– Mohammad Zuhair Khan
Dec 21 at 15:33










3 Answers
3






active

oldest

votes


















5














I'm not sure what kind of functions are allowed but here is a similar one (might be equivalent after some small changes), the differences being it's finite and doesn't require ability to select primes:



For any positive integer $p$, define this function
$$
f(n,p):= leftlceil frac{n-plfloor frac{n}{p}rfloor}{n} rightrceil
$$

If $p$ divides $n$ then $f(n,p)=0$, otherwise $n-plfloor n/prfloorneq 0$ so $f(n,p)=1$.



You can then use this to make the following:
$$
theta(n):= n - nprod_{p=2}^{n-1}f(n,p)
$$

If $n$ is composite then one of the $p$'s will make the product $0$ and hence $theta(n)=n$. Otherwise $n$ is prime and the product is $1$, giving $theta(n)=0$.






share|cite|improve this answer





























    4














    Good try; but there's something that needs fixing. When $n$ is composite, the product diverges to $infty$; so you should define $text {sgn} (infty) = 1$.






    share|cite|improve this answer





















    • Thanks for the advice. But, unless I am mistaken, $+infty gt 0?$
      – Mohammad Zuhair Khan
      Dec 21 at 6:05






    • 2




      @MohammadZuhairKhan Yes; just personally, I would mention that case, since often people assume that youre working in $mathbb{R}$ instead of the extended number system. I would just put it to make sure there's no chance of getting points off.
      – Ovi
      Dec 21 at 6:09










    • Oh okay thank you. Ofcourse, as it is done already, I can not (and would not) update my answer. But is there any other solution for this problem? I have a suspicion that this might be an open problem, or atleast a sensible version of it will.
      – Mohammad Zuhair Khan
      Dec 21 at 6:11










    • @MohammadZuhairKhan I am thinking about it
      – Ovi
      Dec 21 at 6:12










    • @Ovi I would definitely not assume we are working in $mathbb{R}$, $mathbb{N}$ might be a better choice (nitpicks). I also don't see any reason to include such a definition, I would much prefer simpy choosing and noting which set does $n$ belong to. I would go as far as to consider writing $text{sgn}(infty)$ a mistake without well explaining why are you doing that and what do you mean by that.
      – J.E
      Dec 21 at 11:10





















    3














    Instead of the sign function, you could potentially use the Kronecker delta, which is defined as



    $$delta_{mn}=begin{cases}
    1 & text{if }n=m\
    0 & text{if }nneq m
    end{cases}$$



    It basically compares two numbers and gives $1$ if there is a match and $0$ otherwise. By summing over such Kronecker delta's, you could build:



    $$theta(n)=nsum_{i=1}^{infty}delta_{np_i}$$



    (where $p_i$ is the $i$-th prime number). However, I'm wondering if this would be accepted because it kind of bypasses the question of "checking if $n$ is prime". Both our formulas are just a nice rewording of the "text-form" formula given in the question, so I'm not certain this was the kind of answer that was expected.






    share|cite|improve this answer

















    • 1




      To be honest, the entire problem seems to be a test of a student's thought process.
      – Mohammad Zuhair Khan
      Dec 21 at 15:36











    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3048222%2ffind-formula-for-function-of-n-returning-0-if-n-is-composite-and-1-if-n%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    I'm not sure what kind of functions are allowed but here is a similar one (might be equivalent after some small changes), the differences being it's finite and doesn't require ability to select primes:



    For any positive integer $p$, define this function
    $$
    f(n,p):= leftlceil frac{n-plfloor frac{n}{p}rfloor}{n} rightrceil
    $$

    If $p$ divides $n$ then $f(n,p)=0$, otherwise $n-plfloor n/prfloorneq 0$ so $f(n,p)=1$.



    You can then use this to make the following:
    $$
    theta(n):= n - nprod_{p=2}^{n-1}f(n,p)
    $$

    If $n$ is composite then one of the $p$'s will make the product $0$ and hence $theta(n)=n$. Otherwise $n$ is prime and the product is $1$, giving $theta(n)=0$.






    share|cite|improve this answer


























      5














      I'm not sure what kind of functions are allowed but here is a similar one (might be equivalent after some small changes), the differences being it's finite and doesn't require ability to select primes:



      For any positive integer $p$, define this function
      $$
      f(n,p):= leftlceil frac{n-plfloor frac{n}{p}rfloor}{n} rightrceil
      $$

      If $p$ divides $n$ then $f(n,p)=0$, otherwise $n-plfloor n/prfloorneq 0$ so $f(n,p)=1$.



      You can then use this to make the following:
      $$
      theta(n):= n - nprod_{p=2}^{n-1}f(n,p)
      $$

      If $n$ is composite then one of the $p$'s will make the product $0$ and hence $theta(n)=n$. Otherwise $n$ is prime and the product is $1$, giving $theta(n)=0$.






      share|cite|improve this answer
























        5












        5








        5






        I'm not sure what kind of functions are allowed but here is a similar one (might be equivalent after some small changes), the differences being it's finite and doesn't require ability to select primes:



        For any positive integer $p$, define this function
        $$
        f(n,p):= leftlceil frac{n-plfloor frac{n}{p}rfloor}{n} rightrceil
        $$

        If $p$ divides $n$ then $f(n,p)=0$, otherwise $n-plfloor n/prfloorneq 0$ so $f(n,p)=1$.



        You can then use this to make the following:
        $$
        theta(n):= n - nprod_{p=2}^{n-1}f(n,p)
        $$

        If $n$ is composite then one of the $p$'s will make the product $0$ and hence $theta(n)=n$. Otherwise $n$ is prime and the product is $1$, giving $theta(n)=0$.






        share|cite|improve this answer












        I'm not sure what kind of functions are allowed but here is a similar one (might be equivalent after some small changes), the differences being it's finite and doesn't require ability to select primes:



        For any positive integer $p$, define this function
        $$
        f(n,p):= leftlceil frac{n-plfloor frac{n}{p}rfloor}{n} rightrceil
        $$

        If $p$ divides $n$ then $f(n,p)=0$, otherwise $n-plfloor n/prfloorneq 0$ so $f(n,p)=1$.



        You can then use this to make the following:
        $$
        theta(n):= n - nprod_{p=2}^{n-1}f(n,p)
        $$

        If $n$ is composite then one of the $p$'s will make the product $0$ and hence $theta(n)=n$. Otherwise $n$ is prime and the product is $1$, giving $theta(n)=0$.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Dec 21 at 6:48









        Yong Hao Ng

        3,2341220




        3,2341220























            4














            Good try; but there's something that needs fixing. When $n$ is composite, the product diverges to $infty$; so you should define $text {sgn} (infty) = 1$.






            share|cite|improve this answer





















            • Thanks for the advice. But, unless I am mistaken, $+infty gt 0?$
              – Mohammad Zuhair Khan
              Dec 21 at 6:05






            • 2




              @MohammadZuhairKhan Yes; just personally, I would mention that case, since often people assume that youre working in $mathbb{R}$ instead of the extended number system. I would just put it to make sure there's no chance of getting points off.
              – Ovi
              Dec 21 at 6:09










            • Oh okay thank you. Ofcourse, as it is done already, I can not (and would not) update my answer. But is there any other solution for this problem? I have a suspicion that this might be an open problem, or atleast a sensible version of it will.
              – Mohammad Zuhair Khan
              Dec 21 at 6:11










            • @MohammadZuhairKhan I am thinking about it
              – Ovi
              Dec 21 at 6:12










            • @Ovi I would definitely not assume we are working in $mathbb{R}$, $mathbb{N}$ might be a better choice (nitpicks). I also don't see any reason to include such a definition, I would much prefer simpy choosing and noting which set does $n$ belong to. I would go as far as to consider writing $text{sgn}(infty)$ a mistake without well explaining why are you doing that and what do you mean by that.
              – J.E
              Dec 21 at 11:10


















            4














            Good try; but there's something that needs fixing. When $n$ is composite, the product diverges to $infty$; so you should define $text {sgn} (infty) = 1$.






            share|cite|improve this answer





















            • Thanks for the advice. But, unless I am mistaken, $+infty gt 0?$
              – Mohammad Zuhair Khan
              Dec 21 at 6:05






            • 2




              @MohammadZuhairKhan Yes; just personally, I would mention that case, since often people assume that youre working in $mathbb{R}$ instead of the extended number system. I would just put it to make sure there's no chance of getting points off.
              – Ovi
              Dec 21 at 6:09










            • Oh okay thank you. Ofcourse, as it is done already, I can not (and would not) update my answer. But is there any other solution for this problem? I have a suspicion that this might be an open problem, or atleast a sensible version of it will.
              – Mohammad Zuhair Khan
              Dec 21 at 6:11










            • @MohammadZuhairKhan I am thinking about it
              – Ovi
              Dec 21 at 6:12










            • @Ovi I would definitely not assume we are working in $mathbb{R}$, $mathbb{N}$ might be a better choice (nitpicks). I also don't see any reason to include such a definition, I would much prefer simpy choosing and noting which set does $n$ belong to. I would go as far as to consider writing $text{sgn}(infty)$ a mistake without well explaining why are you doing that and what do you mean by that.
              – J.E
              Dec 21 at 11:10
















            4












            4








            4






            Good try; but there's something that needs fixing. When $n$ is composite, the product diverges to $infty$; so you should define $text {sgn} (infty) = 1$.






            share|cite|improve this answer












            Good try; but there's something that needs fixing. When $n$ is composite, the product diverges to $infty$; so you should define $text {sgn} (infty) = 1$.







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered Dec 21 at 6:04









            Ovi

            12.4k1038111




            12.4k1038111












            • Thanks for the advice. But, unless I am mistaken, $+infty gt 0?$
              – Mohammad Zuhair Khan
              Dec 21 at 6:05






            • 2




              @MohammadZuhairKhan Yes; just personally, I would mention that case, since often people assume that youre working in $mathbb{R}$ instead of the extended number system. I would just put it to make sure there's no chance of getting points off.
              – Ovi
              Dec 21 at 6:09










            • Oh okay thank you. Ofcourse, as it is done already, I can not (and would not) update my answer. But is there any other solution for this problem? I have a suspicion that this might be an open problem, or atleast a sensible version of it will.
              – Mohammad Zuhair Khan
              Dec 21 at 6:11










            • @MohammadZuhairKhan I am thinking about it
              – Ovi
              Dec 21 at 6:12










            • @Ovi I would definitely not assume we are working in $mathbb{R}$, $mathbb{N}$ might be a better choice (nitpicks). I also don't see any reason to include such a definition, I would much prefer simpy choosing and noting which set does $n$ belong to. I would go as far as to consider writing $text{sgn}(infty)$ a mistake without well explaining why are you doing that and what do you mean by that.
              – J.E
              Dec 21 at 11:10




















            • Thanks for the advice. But, unless I am mistaken, $+infty gt 0?$
              – Mohammad Zuhair Khan
              Dec 21 at 6:05






            • 2




              @MohammadZuhairKhan Yes; just personally, I would mention that case, since often people assume that youre working in $mathbb{R}$ instead of the extended number system. I would just put it to make sure there's no chance of getting points off.
              – Ovi
              Dec 21 at 6:09










            • Oh okay thank you. Ofcourse, as it is done already, I can not (and would not) update my answer. But is there any other solution for this problem? I have a suspicion that this might be an open problem, or atleast a sensible version of it will.
              – Mohammad Zuhair Khan
              Dec 21 at 6:11










            • @MohammadZuhairKhan I am thinking about it
              – Ovi
              Dec 21 at 6:12










            • @Ovi I would definitely not assume we are working in $mathbb{R}$, $mathbb{N}$ might be a better choice (nitpicks). I also don't see any reason to include such a definition, I would much prefer simpy choosing and noting which set does $n$ belong to. I would go as far as to consider writing $text{sgn}(infty)$ a mistake without well explaining why are you doing that and what do you mean by that.
              – J.E
              Dec 21 at 11:10


















            Thanks for the advice. But, unless I am mistaken, $+infty gt 0?$
            – Mohammad Zuhair Khan
            Dec 21 at 6:05




            Thanks for the advice. But, unless I am mistaken, $+infty gt 0?$
            – Mohammad Zuhair Khan
            Dec 21 at 6:05




            2




            2




            @MohammadZuhairKhan Yes; just personally, I would mention that case, since often people assume that youre working in $mathbb{R}$ instead of the extended number system. I would just put it to make sure there's no chance of getting points off.
            – Ovi
            Dec 21 at 6:09




            @MohammadZuhairKhan Yes; just personally, I would mention that case, since often people assume that youre working in $mathbb{R}$ instead of the extended number system. I would just put it to make sure there's no chance of getting points off.
            – Ovi
            Dec 21 at 6:09












            Oh okay thank you. Ofcourse, as it is done already, I can not (and would not) update my answer. But is there any other solution for this problem? I have a suspicion that this might be an open problem, or atleast a sensible version of it will.
            – Mohammad Zuhair Khan
            Dec 21 at 6:11




            Oh okay thank you. Ofcourse, as it is done already, I can not (and would not) update my answer. But is there any other solution for this problem? I have a suspicion that this might be an open problem, or atleast a sensible version of it will.
            – Mohammad Zuhair Khan
            Dec 21 at 6:11












            @MohammadZuhairKhan I am thinking about it
            – Ovi
            Dec 21 at 6:12




            @MohammadZuhairKhan I am thinking about it
            – Ovi
            Dec 21 at 6:12












            @Ovi I would definitely not assume we are working in $mathbb{R}$, $mathbb{N}$ might be a better choice (nitpicks). I also don't see any reason to include such a definition, I would much prefer simpy choosing and noting which set does $n$ belong to. I would go as far as to consider writing $text{sgn}(infty)$ a mistake without well explaining why are you doing that and what do you mean by that.
            – J.E
            Dec 21 at 11:10






            @Ovi I would definitely not assume we are working in $mathbb{R}$, $mathbb{N}$ might be a better choice (nitpicks). I also don't see any reason to include such a definition, I would much prefer simpy choosing and noting which set does $n$ belong to. I would go as far as to consider writing $text{sgn}(infty)$ a mistake without well explaining why are you doing that and what do you mean by that.
            – J.E
            Dec 21 at 11:10













            3














            Instead of the sign function, you could potentially use the Kronecker delta, which is defined as



            $$delta_{mn}=begin{cases}
            1 & text{if }n=m\
            0 & text{if }nneq m
            end{cases}$$



            It basically compares two numbers and gives $1$ if there is a match and $0$ otherwise. By summing over such Kronecker delta's, you could build:



            $$theta(n)=nsum_{i=1}^{infty}delta_{np_i}$$



            (where $p_i$ is the $i$-th prime number). However, I'm wondering if this would be accepted because it kind of bypasses the question of "checking if $n$ is prime". Both our formulas are just a nice rewording of the "text-form" formula given in the question, so I'm not certain this was the kind of answer that was expected.






            share|cite|improve this answer

















            • 1




              To be honest, the entire problem seems to be a test of a student's thought process.
              – Mohammad Zuhair Khan
              Dec 21 at 15:36
















            3














            Instead of the sign function, you could potentially use the Kronecker delta, which is defined as



            $$delta_{mn}=begin{cases}
            1 & text{if }n=m\
            0 & text{if }nneq m
            end{cases}$$



            It basically compares two numbers and gives $1$ if there is a match and $0$ otherwise. By summing over such Kronecker delta's, you could build:



            $$theta(n)=nsum_{i=1}^{infty}delta_{np_i}$$



            (where $p_i$ is the $i$-th prime number). However, I'm wondering if this would be accepted because it kind of bypasses the question of "checking if $n$ is prime". Both our formulas are just a nice rewording of the "text-form" formula given in the question, so I'm not certain this was the kind of answer that was expected.






            share|cite|improve this answer

















            • 1




              To be honest, the entire problem seems to be a test of a student's thought process.
              – Mohammad Zuhair Khan
              Dec 21 at 15:36














            3












            3








            3






            Instead of the sign function, you could potentially use the Kronecker delta, which is defined as



            $$delta_{mn}=begin{cases}
            1 & text{if }n=m\
            0 & text{if }nneq m
            end{cases}$$



            It basically compares two numbers and gives $1$ if there is a match and $0$ otherwise. By summing over such Kronecker delta's, you could build:



            $$theta(n)=nsum_{i=1}^{infty}delta_{np_i}$$



            (where $p_i$ is the $i$-th prime number). However, I'm wondering if this would be accepted because it kind of bypasses the question of "checking if $n$ is prime". Both our formulas are just a nice rewording of the "text-form" formula given in the question, so I'm not certain this was the kind of answer that was expected.






            share|cite|improve this answer












            Instead of the sign function, you could potentially use the Kronecker delta, which is defined as



            $$delta_{mn}=begin{cases}
            1 & text{if }n=m\
            0 & text{if }nneq m
            end{cases}$$



            It basically compares two numbers and gives $1$ if there is a match and $0$ otherwise. By summing over such Kronecker delta's, you could build:



            $$theta(n)=nsum_{i=1}^{infty}delta_{np_i}$$



            (where $p_i$ is the $i$-th prime number). However, I'm wondering if this would be accepted because it kind of bypasses the question of "checking if $n$ is prime". Both our formulas are just a nice rewording of the "text-form" formula given in the question, so I'm not certain this was the kind of answer that was expected.







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered Dec 21 at 6:39









            orion2112

            461210




            461210








            • 1




              To be honest, the entire problem seems to be a test of a student's thought process.
              – Mohammad Zuhair Khan
              Dec 21 at 15:36














            • 1




              To be honest, the entire problem seems to be a test of a student's thought process.
              – Mohammad Zuhair Khan
              Dec 21 at 15:36








            1




            1




            To be honest, the entire problem seems to be a test of a student's thought process.
            – Mohammad Zuhair Khan
            Dec 21 at 15:36




            To be honest, the entire problem seems to be a test of a student's thought process.
            – Mohammad Zuhair Khan
            Dec 21 at 15:36


















            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3048222%2ffind-formula-for-function-of-n-returning-0-if-n-is-composite-and-1-if-n%23new-answer', 'question_page');
            }
            );

            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







            Popular posts from this blog

            Сан-Квентин

            8-я гвардейская общевойсковая армия

            Алькесар