Number of solutions related to fermat's last theorem

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












Can anyone tell me how will we calculate number of solutions of



$x^k + y^k - z^k equiv 0 mod p$



And $0<x,y,z<p$



$1le p le10^6 $



$1le k le 10^18$



It is related to fermat's last theorem somehow



For eg:-



$P=5$ and $K=4$ has $2$ solutions



For $k=1~x,y,z=1,1,2$



For $k=2$ no soln



For $k=3~x,y,z=1,3,2$



For $k=4$ no soln







share|cite|improve this question





















  • Please use MathJax to format your questions
    – saulspatz
    Jul 22 at 20:06










  • Am I right in assuming that $p$ is prime? Which programming contest is this from?
    – Hagen von Eitzen
    Jul 22 at 20:08











  • @HagenvonEitzen yepp p is prime ques is from hackerearth july circuits
    – dank uploader
    Jul 22 at 20:18










  • Perhaps more closely related to Fermat's little theorem.
    – saulspatz
    Jul 22 at 20:35














up vote
-1
down vote

favorite












Can anyone tell me how will we calculate number of solutions of



$x^k + y^k - z^k equiv 0 mod p$



And $0<x,y,z<p$



$1le p le10^6 $



$1le k le 10^18$



It is related to fermat's last theorem somehow



For eg:-



$P=5$ and $K=4$ has $2$ solutions



For $k=1~x,y,z=1,1,2$



For $k=2$ no soln



For $k=3~x,y,z=1,3,2$



For $k=4$ no soln







share|cite|improve this question





















  • Please use MathJax to format your questions
    – saulspatz
    Jul 22 at 20:06










  • Am I right in assuming that $p$ is prime? Which programming contest is this from?
    – Hagen von Eitzen
    Jul 22 at 20:08











  • @HagenvonEitzen yepp p is prime ques is from hackerearth july circuits
    – dank uploader
    Jul 22 at 20:18










  • Perhaps more closely related to Fermat's little theorem.
    – saulspatz
    Jul 22 at 20:35












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











Can anyone tell me how will we calculate number of solutions of



$x^k + y^k - z^k equiv 0 mod p$



And $0<x,y,z<p$



$1le p le10^6 $



$1le k le 10^18$



It is related to fermat's last theorem somehow



For eg:-



$P=5$ and $K=4$ has $2$ solutions



For $k=1~x,y,z=1,1,2$



For $k=2$ no soln



For $k=3~x,y,z=1,3,2$



For $k=4$ no soln







share|cite|improve this question













Can anyone tell me how will we calculate number of solutions of



$x^k + y^k - z^k equiv 0 mod p$



And $0<x,y,z<p$



$1le p le10^6 $



$1le k le 10^18$



It is related to fermat's last theorem somehow



For eg:-



$P=5$ and $K=4$ has $2$ solutions



For $k=1~x,y,z=1,1,2$



For $k=2$ no soln



For $k=3~x,y,z=1,3,2$



For $k=4$ no soln









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 22 at 20:19
























asked Jul 22 at 20:02









dank uploader

13




13











  • Please use MathJax to format your questions
    – saulspatz
    Jul 22 at 20:06










  • Am I right in assuming that $p$ is prime? Which programming contest is this from?
    – Hagen von Eitzen
    Jul 22 at 20:08











  • @HagenvonEitzen yepp p is prime ques is from hackerearth july circuits
    – dank uploader
    Jul 22 at 20:18










  • Perhaps more closely related to Fermat's little theorem.
    – saulspatz
    Jul 22 at 20:35
















  • Please use MathJax to format your questions
    – saulspatz
    Jul 22 at 20:06










  • Am I right in assuming that $p$ is prime? Which programming contest is this from?
    – Hagen von Eitzen
    Jul 22 at 20:08











  • @HagenvonEitzen yepp p is prime ques is from hackerearth july circuits
    – dank uploader
    Jul 22 at 20:18










  • Perhaps more closely related to Fermat's little theorem.
    – saulspatz
    Jul 22 at 20:35















Please use MathJax to format your questions
– saulspatz
Jul 22 at 20:06




Please use MathJax to format your questions
– saulspatz
Jul 22 at 20:06












Am I right in assuming that $p$ is prime? Which programming contest is this from?
– Hagen von Eitzen
Jul 22 at 20:08





Am I right in assuming that $p$ is prime? Which programming contest is this from?
– Hagen von Eitzen
Jul 22 at 20:08













@HagenvonEitzen yepp p is prime ques is from hackerearth july circuits
– dank uploader
Jul 22 at 20:18




@HagenvonEitzen yepp p is prime ques is from hackerearth july circuits
– dank uploader
Jul 22 at 20:18












Perhaps more closely related to Fermat's little theorem.
– saulspatz
Jul 22 at 20:35




Perhaps more closely related to Fermat's little theorem.
– saulspatz
Jul 22 at 20:35










2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










One can reduce the problem a lot:



By Fermat's little theorem, $a^p-1equiv 1pmod p$ for all $anotequiv 0pmod p$. It follows that a solution for $k$ exists iff a solution for $kbmodp-1$ exists, i.e., we need only check $0le k<p-1$. In fact, as taking inverses $bmod p$ is a bijection, a solution f $k$ exists iff a solution for $p-1-k$ exist, i.e., we need only check $0le klefracp-12$. For small $p$, we can thus simply loop over all possible values and check. We immediately get that there is no solution for $k=0$ (as $1+1notequiv 1pmod p$): We also immediately get that $(1,1,2)$ is a solutions for $k=1$ (except when $p=2$), and $(3,4,5)$ is a solution for $k=2$ at least for $p>5$. For $k=fracp-12$, there is no solution (provided $p>3$): $a^2kequiv 1$ implies $a^kequiv pm1$



If $(x,y,z)$ is a solution for some $k$, then so is $(xy^-1bmod p,1,zy^-1bmod p)$, i.e., we need only look for consecutive $k$th powers.



This suggests the following: Find a generator $a$ and for $1le x<p$, find $ell(x)$ such that $a^ell(x)equiv xpmod p$. This can easily be prepared in $plog(p)$ time. Next, loop over $x=1,ldots, p-2$ and note that a solution exists for $k=gcd(ell(x),ell(x+1))$ and any divisor thereof.






share|cite|improve this answer





















  • Can you explain this with an example when p=23 and k=20 what can be the number of possible values of k such that a solution exists for x^k+y^k=z^k (mod p) That would be a great help thanks
    – dank uploader
    Jul 23 at 9:10










  • Also what is l(x) here
    – dank uploader
    Jul 23 at 14:10

















up vote
0
down vote













If you want the statement to hold "for any $x,y,z$" as it is now, then if you plug $x=y=z=1$ you get that $p|1$ which is a contradiction






share|cite|improve this answer





















    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    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%2f2859719%2fnumber-of-solutions-related-to-fermats-last-theorem%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    One can reduce the problem a lot:



    By Fermat's little theorem, $a^p-1equiv 1pmod p$ for all $anotequiv 0pmod p$. It follows that a solution for $k$ exists iff a solution for $kbmodp-1$ exists, i.e., we need only check $0le k<p-1$. In fact, as taking inverses $bmod p$ is a bijection, a solution f $k$ exists iff a solution for $p-1-k$ exist, i.e., we need only check $0le klefracp-12$. For small $p$, we can thus simply loop over all possible values and check. We immediately get that there is no solution for $k=0$ (as $1+1notequiv 1pmod p$): We also immediately get that $(1,1,2)$ is a solutions for $k=1$ (except when $p=2$), and $(3,4,5)$ is a solution for $k=2$ at least for $p>5$. For $k=fracp-12$, there is no solution (provided $p>3$): $a^2kequiv 1$ implies $a^kequiv pm1$



    If $(x,y,z)$ is a solution for some $k$, then so is $(xy^-1bmod p,1,zy^-1bmod p)$, i.e., we need only look for consecutive $k$th powers.



    This suggests the following: Find a generator $a$ and for $1le x<p$, find $ell(x)$ such that $a^ell(x)equiv xpmod p$. This can easily be prepared in $plog(p)$ time. Next, loop over $x=1,ldots, p-2$ and note that a solution exists for $k=gcd(ell(x),ell(x+1))$ and any divisor thereof.






    share|cite|improve this answer





















    • Can you explain this with an example when p=23 and k=20 what can be the number of possible values of k such that a solution exists for x^k+y^k=z^k (mod p) That would be a great help thanks
      – dank uploader
      Jul 23 at 9:10










    • Also what is l(x) here
      – dank uploader
      Jul 23 at 14:10














    up vote
    0
    down vote



    accepted










    One can reduce the problem a lot:



    By Fermat's little theorem, $a^p-1equiv 1pmod p$ for all $anotequiv 0pmod p$. It follows that a solution for $k$ exists iff a solution for $kbmodp-1$ exists, i.e., we need only check $0le k<p-1$. In fact, as taking inverses $bmod p$ is a bijection, a solution f $k$ exists iff a solution for $p-1-k$ exist, i.e., we need only check $0le klefracp-12$. For small $p$, we can thus simply loop over all possible values and check. We immediately get that there is no solution for $k=0$ (as $1+1notequiv 1pmod p$): We also immediately get that $(1,1,2)$ is a solutions for $k=1$ (except when $p=2$), and $(3,4,5)$ is a solution for $k=2$ at least for $p>5$. For $k=fracp-12$, there is no solution (provided $p>3$): $a^2kequiv 1$ implies $a^kequiv pm1$



    If $(x,y,z)$ is a solution for some $k$, then so is $(xy^-1bmod p,1,zy^-1bmod p)$, i.e., we need only look for consecutive $k$th powers.



    This suggests the following: Find a generator $a$ and for $1le x<p$, find $ell(x)$ such that $a^ell(x)equiv xpmod p$. This can easily be prepared in $plog(p)$ time. Next, loop over $x=1,ldots, p-2$ and note that a solution exists for $k=gcd(ell(x),ell(x+1))$ and any divisor thereof.






    share|cite|improve this answer





















    • Can you explain this with an example when p=23 and k=20 what can be the number of possible values of k such that a solution exists for x^k+y^k=z^k (mod p) That would be a great help thanks
      – dank uploader
      Jul 23 at 9:10










    • Also what is l(x) here
      – dank uploader
      Jul 23 at 14:10












    up vote
    0
    down vote



    accepted







    up vote
    0
    down vote



    accepted






    One can reduce the problem a lot:



    By Fermat's little theorem, $a^p-1equiv 1pmod p$ for all $anotequiv 0pmod p$. It follows that a solution for $k$ exists iff a solution for $kbmodp-1$ exists, i.e., we need only check $0le k<p-1$. In fact, as taking inverses $bmod p$ is a bijection, a solution f $k$ exists iff a solution for $p-1-k$ exist, i.e., we need only check $0le klefracp-12$. For small $p$, we can thus simply loop over all possible values and check. We immediately get that there is no solution for $k=0$ (as $1+1notequiv 1pmod p$): We also immediately get that $(1,1,2)$ is a solutions for $k=1$ (except when $p=2$), and $(3,4,5)$ is a solution for $k=2$ at least for $p>5$. For $k=fracp-12$, there is no solution (provided $p>3$): $a^2kequiv 1$ implies $a^kequiv pm1$



    If $(x,y,z)$ is a solution for some $k$, then so is $(xy^-1bmod p,1,zy^-1bmod p)$, i.e., we need only look for consecutive $k$th powers.



    This suggests the following: Find a generator $a$ and for $1le x<p$, find $ell(x)$ such that $a^ell(x)equiv xpmod p$. This can easily be prepared in $plog(p)$ time. Next, loop over $x=1,ldots, p-2$ and note that a solution exists for $k=gcd(ell(x),ell(x+1))$ and any divisor thereof.






    share|cite|improve this answer













    One can reduce the problem a lot:



    By Fermat's little theorem, $a^p-1equiv 1pmod p$ for all $anotequiv 0pmod p$. It follows that a solution for $k$ exists iff a solution for $kbmodp-1$ exists, i.e., we need only check $0le k<p-1$. In fact, as taking inverses $bmod p$ is a bijection, a solution f $k$ exists iff a solution for $p-1-k$ exist, i.e., we need only check $0le klefracp-12$. For small $p$, we can thus simply loop over all possible values and check. We immediately get that there is no solution for $k=0$ (as $1+1notequiv 1pmod p$): We also immediately get that $(1,1,2)$ is a solutions for $k=1$ (except when $p=2$), and $(3,4,5)$ is a solution for $k=2$ at least for $p>5$. For $k=fracp-12$, there is no solution (provided $p>3$): $a^2kequiv 1$ implies $a^kequiv pm1$



    If $(x,y,z)$ is a solution for some $k$, then so is $(xy^-1bmod p,1,zy^-1bmod p)$, i.e., we need only look for consecutive $k$th powers.



    This suggests the following: Find a generator $a$ and for $1le x<p$, find $ell(x)$ such that $a^ell(x)equiv xpmod p$. This can easily be prepared in $plog(p)$ time. Next, loop over $x=1,ldots, p-2$ and note that a solution exists for $k=gcd(ell(x),ell(x+1))$ and any divisor thereof.







    share|cite|improve this answer













    share|cite|improve this answer



    share|cite|improve this answer











    answered Jul 22 at 21:04









    Hagen von Eitzen

    265k20258477




    265k20258477











    • Can you explain this with an example when p=23 and k=20 what can be the number of possible values of k such that a solution exists for x^k+y^k=z^k (mod p) That would be a great help thanks
      – dank uploader
      Jul 23 at 9:10










    • Also what is l(x) here
      – dank uploader
      Jul 23 at 14:10
















    • Can you explain this with an example when p=23 and k=20 what can be the number of possible values of k such that a solution exists for x^k+y^k=z^k (mod p) That would be a great help thanks
      – dank uploader
      Jul 23 at 9:10










    • Also what is l(x) here
      – dank uploader
      Jul 23 at 14:10















    Can you explain this with an example when p=23 and k=20 what can be the number of possible values of k such that a solution exists for x^k+y^k=z^k (mod p) That would be a great help thanks
    – dank uploader
    Jul 23 at 9:10




    Can you explain this with an example when p=23 and k=20 what can be the number of possible values of k such that a solution exists for x^k+y^k=z^k (mod p) That would be a great help thanks
    – dank uploader
    Jul 23 at 9:10












    Also what is l(x) here
    – dank uploader
    Jul 23 at 14:10




    Also what is l(x) here
    – dank uploader
    Jul 23 at 14:10










    up vote
    0
    down vote













    If you want the statement to hold "for any $x,y,z$" as it is now, then if you plug $x=y=z=1$ you get that $p|1$ which is a contradiction






    share|cite|improve this answer

























      up vote
      0
      down vote













      If you want the statement to hold "for any $x,y,z$" as it is now, then if you plug $x=y=z=1$ you get that $p|1$ which is a contradiction






      share|cite|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        If you want the statement to hold "for any $x,y,z$" as it is now, then if you plug $x=y=z=1$ you get that $p|1$ which is a contradiction






        share|cite|improve this answer













        If you want the statement to hold "for any $x,y,z$" as it is now, then if you plug $x=y=z=1$ you get that $p|1$ which is a contradiction







        share|cite|improve this answer













        share|cite|improve this answer



        share|cite|improve this answer











        answered Jul 22 at 20:14









        asdf

        3,378519




        3,378519






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2859719%2fnumber-of-solutions-related-to-fermats-last-theorem%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What is the equation of a 3D cone with generalised tilt?

            Color the edges and diagonals of a regular polygon

            Relationship between determinant of matrix and determinant of adjoint?