Is there a way to determine exactly the difference between $N$th & $(N+1)$th prime number?Most efficient algorithm for nth prime, deterministic and probabilistic?Determine whether a number is primeAlgorithm to generate a prime number which is n-digits longHow to identify the slowest prime number in Sieve of Eratosthenes AlgorithmFind the smallest prime positive integer in each of the following.Is there an algorithm to find minimum number of undefinable words in a dictionary?Is there a known fast algorithm to find the $k^textth$ root modulo a prime?Find the greatest prime number with 7 as the last digit in $1,ldots, n$Prime number sieve using difference of two squaresEstimate of time required for prime factorization of large numberTime complexity analysis of finding the largest prime divisor

Are these two graphs isomorphic? Why/Why not?

Are E natural minor and B harmonic minor related?

Which country has more?

Do Paladin Auras of Differing Oaths Stack?

If sound is a longitudinal wave, why can we hear it if our ears aren't aligned with the propagation direction?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

Is there a way to make cleveref distinguish two environments with the same counter?

What do you call someone who likes to pick fights?

The preposition for the verb (avenge) - avenge sb/sth (on OR from) sb

Was it really inappropriate to write a pull request for the company I interviewed with?

Finding the minimum value of a function without using Calculus

Volume of hyperbola revolved about the y -axis

Does an unused member variable take up memory?

School performs periodic password audits. Is my password compromised?

Is there stress on two letters on the word стоят

Do black holes violate the conservation of mass?

Is it possible to clone a polymorphic object without manually adding overridden clone method into each derived class in C++?

Did Amazon pay $0 in taxes last year?

What does *dead* mean in *What do you mean, dead?*?

Is divide-by-zero a security vulnerability?

Idiom for feeling after taking risk and someone else being rewarded

Computation logic of Partway in TikZ

Can the Witch Sight warlock invocation see through the Mirror Image spell?

How to educate team mate to take screenshots for bugs with out unwanted stuff



Is there a way to determine exactly the difference between $N$th & $(N+1)$th prime number?


Most efficient algorithm for nth prime, deterministic and probabilistic?Determine whether a number is primeAlgorithm to generate a prime number which is n-digits longHow to identify the slowest prime number in Sieve of Eratosthenes AlgorithmFind the smallest prime positive integer in each of the following.Is there an algorithm to find minimum number of undefinable words in a dictionary?Is there a known fast algorithm to find the $k^textth$ root modulo a prime?Find the greatest prime number with 7 as the last digit in $1,ldots, n$Prime number sieve using difference of two squaresEstimate of time required for prime factorization of large numberTime complexity analysis of finding the largest prime divisor













2












$begingroup$


So I was trying to find the time complexity of an algorithm to find the $N$th prime number (where $N$ could be any positive integer).



So is there any way to exactly determine how far $(N+1)$th prime number will be if $N$th prime number is already known ?










share|cite|improve this question











$endgroup$







  • 6




    $begingroup$
    Of course there is a way – just check numbers going up from the $n$th prime until you find the next prime. But you probably want to know whether there is a more efficient method, or maybe you even want to know the best method. It seems that knowing the $n$ prime helps very little in finding the next one. E.g., if you want to know the first prime after $10^1000$, and I tell you the last prime before $10^1000$, that doesn't give you very much help at all.
    $endgroup$
    – Gerry Myerson
    Jan 6 at 23:11















2












$begingroup$


So I was trying to find the time complexity of an algorithm to find the $N$th prime number (where $N$ could be any positive integer).



So is there any way to exactly determine how far $(N+1)$th prime number will be if $N$th prime number is already known ?










share|cite|improve this question











$endgroup$







  • 6




    $begingroup$
    Of course there is a way – just check numbers going up from the $n$th prime until you find the next prime. But you probably want to know whether there is a more efficient method, or maybe you even want to know the best method. It seems that knowing the $n$ prime helps very little in finding the next one. E.g., if you want to know the first prime after $10^1000$, and I tell you the last prime before $10^1000$, that doesn't give you very much help at all.
    $endgroup$
    – Gerry Myerson
    Jan 6 at 23:11













2












2








2





$begingroup$


So I was trying to find the time complexity of an algorithm to find the $N$th prime number (where $N$ could be any positive integer).



So is there any way to exactly determine how far $(N+1)$th prime number will be if $N$th prime number is already known ?










share|cite|improve this question











$endgroup$




So I was trying to find the time complexity of an algorithm to find the $N$th prime number (where $N$ could be any positive integer).



So is there any way to exactly determine how far $(N+1)$th prime number will be if $N$th prime number is already known ?







prime-numbers algorithms prime-gaps






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Jan 6 at 23:21









Gnumbertester

670114




670114










asked Jan 6 at 23:08









Aashish Loknath PanigrahiAashish Loknath Panigrahi

23117




23117







  • 6




    $begingroup$
    Of course there is a way – just check numbers going up from the $n$th prime until you find the next prime. But you probably want to know whether there is a more efficient method, or maybe you even want to know the best method. It seems that knowing the $n$ prime helps very little in finding the next one. E.g., if you want to know the first prime after $10^1000$, and I tell you the last prime before $10^1000$, that doesn't give you very much help at all.
    $endgroup$
    – Gerry Myerson
    Jan 6 at 23:11












  • 6




    $begingroup$
    Of course there is a way – just check numbers going up from the $n$th prime until you find the next prime. But you probably want to know whether there is a more efficient method, or maybe you even want to know the best method. It seems that knowing the $n$ prime helps very little in finding the next one. E.g., if you want to know the first prime after $10^1000$, and I tell you the last prime before $10^1000$, that doesn't give you very much help at all.
    $endgroup$
    – Gerry Myerson
    Jan 6 at 23:11







6




6




$begingroup$
Of course there is a way – just check numbers going up from the $n$th prime until you find the next prime. But you probably want to know whether there is a more efficient method, or maybe you even want to know the best method. It seems that knowing the $n$ prime helps very little in finding the next one. E.g., if you want to know the first prime after $10^1000$, and I tell you the last prime before $10^1000$, that doesn't give you very much help at all.
$endgroup$
– Gerry Myerson
Jan 6 at 23:11




$begingroup$
Of course there is a way – just check numbers going up from the $n$th prime until you find the next prime. But you probably want to know whether there is a more efficient method, or maybe you even want to know the best method. It seems that knowing the $n$ prime helps very little in finding the next one. E.g., if you want to know the first prime after $10^1000$, and I tell you the last prime before $10^1000$, that doesn't give you very much help at all.
$endgroup$
– Gerry Myerson
Jan 6 at 23:11










3 Answers
3






active

oldest

votes


















0












$begingroup$

It depends on what you call large, and what theory you use. Using the fact all primes greater than 3 are 1 or -1 mod 6 and a Sieve of Sundaram style argument, you can show that any natural number n, of certain forms will create at most 1 half ( one prime one composite) of a twin prime pair. Specifically, the following make at least one of 6n+1 or 6n-1 composite:
$$begincases6n+1,quadtextn=(6j+1)k+j or n=(6j-1)k-j\6n-1,quadtextn=(6j+1)k-jendcases$$
Where, k,j>0, in the case of semiprimes with roughly same size factors, j,k will be close together making each roughly $frac16sqrt p$ p being the number you are trying to factor. Of course, the twin prime conjecture, says there's no point after which, all natural numbers are of these forms. Good luck.






share|cite|improve this answer











$endgroup$




















    0












    $begingroup$

    You're got what looks like two questions.




    1. The time complexity of the nth prime. In practice it is $Obig(fracn^2/3log^2nbig)$ using fast prime count algorithms. In theory this could be lowered to something on the order of $O(n^1/2)$. See:



      • Most efficient algorithm for nth prime, deterministic and probabilistic?

      • https://cs.stackexchange.com/questions/10683/what-is-the-time-complexity-of-generating-n-th-prime-number

      • primesieve README



    2. Does knowing P(n-1) allow one to quickly find P(n)? Yes, in the sense that we have reduced the problem to a single nextprime call. Once beyond trivial sizes, this is just a loop calling isprime. One might want to use a wheel or a partial sieve to skip obvious composites.



      See Cramér's conjecture for a thought on how long this would take. In practice this is quite efficient, with inputs of thousands of digits being straightforward to calculate. You can look up the concept of "merits" for gaps. On average you'll find the next prime about $log n$ away. For large inputs, I found sieving to a distance of $30 log n$ (30 merits) was plenty to get excellent performance with exceptionally few gaps that need to look farther.



      Knowing the previous prime hasn't really given us any special information though, as Gerry pointed out.







    share|cite|improve this answer











    $endgroup$




















      -2












      $begingroup$

      A good method for the operation of a prime number program is to output only the primes between an upper-bound and the upper-bound - k . Then the program just appears to be jumping from one section of a list to the other on each computation. Of course required consecutive primes are obviously found within the range of the output.



      Here is my previous post:



      Odd numbers can be wheeled in multiplications to output only odd composite numbers. Then the odd numbers that are not output are the prime numbers.



      Now each inner loop can stop at a multiplication that reaches the value of an upper-bound and the outer loop can stop at the square root of the upper-bound.



      Furthermore the loops from the number 11 can increment with 2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10 ... as continuing and repeating. That's a big performance gain because multiples of 3, 5, and 7 are removed from the sequence of odd numbers.



      A prime number application really works best when outputting prime numbers between an upper bound and the upper bound - k. Then the application appears to be just scrolling sections (or jumping to sections) of a list on each computation. And in this case the loop increments are really only needed on the outer loop because a single division operation jumps over unneeded sections of the inner loop. Of course, array subscript locations can work with translations such that the same array can handle any of the segmented computations and then not use very much memory.






      share|cite|improve this answer











      $endgroup$








      • 4




        $begingroup$
        My only comment is: "Huh?"
        $endgroup$
        – Matt Samuel
        Jan 6 at 23:41










      • $begingroup$
        Description of a computational computer program is an algorithm.
        $endgroup$
        – S Spring
        Jan 7 at 0:25










      • $begingroup$
        I don’t understand any of this, but it sounds like exhaustive search which doesn’t help OP. Whatever it is, it’s not an answer.
        $endgroup$
        – Randall
        Jan 7 at 0:28










      • $begingroup$
        The OP doesn't need the primes to be counted but only needs the next prime after a counted prime. The algorithm does work in the situation. But odd composite numbers are output to an array and odd positions in the array that don't receive an output represent the prime numbers. Sections of prime numbers less than the upper-bound - k are jumped over in the computation.
        $endgroup$
        – S Spring
        Jan 7 at 0:40











      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%2f3064501%2fis-there-a-way-to-determine-exactly-the-difference-between-nth-n1th-pri%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









      0












      $begingroup$

      It depends on what you call large, and what theory you use. Using the fact all primes greater than 3 are 1 or -1 mod 6 and a Sieve of Sundaram style argument, you can show that any natural number n, of certain forms will create at most 1 half ( one prime one composite) of a twin prime pair. Specifically, the following make at least one of 6n+1 or 6n-1 composite:
      $$begincases6n+1,quadtextn=(6j+1)k+j or n=(6j-1)k-j\6n-1,quadtextn=(6j+1)k-jendcases$$
      Where, k,j>0, in the case of semiprimes with roughly same size factors, j,k will be close together making each roughly $frac16sqrt p$ p being the number you are trying to factor. Of course, the twin prime conjecture, says there's no point after which, all natural numbers are of these forms. Good luck.






      share|cite|improve this answer











      $endgroup$

















        0












        $begingroup$

        It depends on what you call large, and what theory you use. Using the fact all primes greater than 3 are 1 or -1 mod 6 and a Sieve of Sundaram style argument, you can show that any natural number n, of certain forms will create at most 1 half ( one prime one composite) of a twin prime pair. Specifically, the following make at least one of 6n+1 or 6n-1 composite:
        $$begincases6n+1,quadtextn=(6j+1)k+j or n=(6j-1)k-j\6n-1,quadtextn=(6j+1)k-jendcases$$
        Where, k,j>0, in the case of semiprimes with roughly same size factors, j,k will be close together making each roughly $frac16sqrt p$ p being the number you are trying to factor. Of course, the twin prime conjecture, says there's no point after which, all natural numbers are of these forms. Good luck.






        share|cite|improve this answer











        $endgroup$















          0












          0








          0





          $begingroup$

          It depends on what you call large, and what theory you use. Using the fact all primes greater than 3 are 1 or -1 mod 6 and a Sieve of Sundaram style argument, you can show that any natural number n, of certain forms will create at most 1 half ( one prime one composite) of a twin prime pair. Specifically, the following make at least one of 6n+1 or 6n-1 composite:
          $$begincases6n+1,quadtextn=(6j+1)k+j or n=(6j-1)k-j\6n-1,quadtextn=(6j+1)k-jendcases$$
          Where, k,j>0, in the case of semiprimes with roughly same size factors, j,k will be close together making each roughly $frac16sqrt p$ p being the number you are trying to factor. Of course, the twin prime conjecture, says there's no point after which, all natural numbers are of these forms. Good luck.






          share|cite|improve this answer











          $endgroup$



          It depends on what you call large, and what theory you use. Using the fact all primes greater than 3 are 1 or -1 mod 6 and a Sieve of Sundaram style argument, you can show that any natural number n, of certain forms will create at most 1 half ( one prime one composite) of a twin prime pair. Specifically, the following make at least one of 6n+1 or 6n-1 composite:
          $$begincases6n+1,quadtextn=(6j+1)k+j or n=(6j-1)k-j\6n-1,quadtextn=(6j+1)k-jendcases$$
          Where, k,j>0, in the case of semiprimes with roughly same size factors, j,k will be close together making each roughly $frac16sqrt p$ p being the number you are trying to factor. Of course, the twin prime conjecture, says there's no point after which, all natural numbers are of these forms. Good luck.







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited 2 days ago

























          answered 2 days ago









          Roddy MacPheeRoddy MacPhee

          27014




          27014





















              0












              $begingroup$

              You're got what looks like two questions.




              1. The time complexity of the nth prime. In practice it is $Obig(fracn^2/3log^2nbig)$ using fast prime count algorithms. In theory this could be lowered to something on the order of $O(n^1/2)$. See:



                • Most efficient algorithm for nth prime, deterministic and probabilistic?

                • https://cs.stackexchange.com/questions/10683/what-is-the-time-complexity-of-generating-n-th-prime-number

                • primesieve README



              2. Does knowing P(n-1) allow one to quickly find P(n)? Yes, in the sense that we have reduced the problem to a single nextprime call. Once beyond trivial sizes, this is just a loop calling isprime. One might want to use a wheel or a partial sieve to skip obvious composites.



                See Cramér's conjecture for a thought on how long this would take. In practice this is quite efficient, with inputs of thousands of digits being straightforward to calculate. You can look up the concept of "merits" for gaps. On average you'll find the next prime about $log n$ away. For large inputs, I found sieving to a distance of $30 log n$ (30 merits) was plenty to get excellent performance with exceptionally few gaps that need to look farther.



                Knowing the previous prime hasn't really given us any special information though, as Gerry pointed out.







              share|cite|improve this answer











              $endgroup$

















                0












                $begingroup$

                You're got what looks like two questions.




                1. The time complexity of the nth prime. In practice it is $Obig(fracn^2/3log^2nbig)$ using fast prime count algorithms. In theory this could be lowered to something on the order of $O(n^1/2)$. See:



                  • Most efficient algorithm for nth prime, deterministic and probabilistic?

                  • https://cs.stackexchange.com/questions/10683/what-is-the-time-complexity-of-generating-n-th-prime-number

                  • primesieve README



                2. Does knowing P(n-1) allow one to quickly find P(n)? Yes, in the sense that we have reduced the problem to a single nextprime call. Once beyond trivial sizes, this is just a loop calling isprime. One might want to use a wheel or a partial sieve to skip obvious composites.



                  See Cramér's conjecture for a thought on how long this would take. In practice this is quite efficient, with inputs of thousands of digits being straightforward to calculate. You can look up the concept of "merits" for gaps. On average you'll find the next prime about $log n$ away. For large inputs, I found sieving to a distance of $30 log n$ (30 merits) was plenty to get excellent performance with exceptionally few gaps that need to look farther.



                  Knowing the previous prime hasn't really given us any special information though, as Gerry pointed out.







                share|cite|improve this answer











                $endgroup$















                  0












                  0








                  0





                  $begingroup$

                  You're got what looks like two questions.




                  1. The time complexity of the nth prime. In practice it is $Obig(fracn^2/3log^2nbig)$ using fast prime count algorithms. In theory this could be lowered to something on the order of $O(n^1/2)$. See:



                    • Most efficient algorithm for nth prime, deterministic and probabilistic?

                    • https://cs.stackexchange.com/questions/10683/what-is-the-time-complexity-of-generating-n-th-prime-number

                    • primesieve README



                  2. Does knowing P(n-1) allow one to quickly find P(n)? Yes, in the sense that we have reduced the problem to a single nextprime call. Once beyond trivial sizes, this is just a loop calling isprime. One might want to use a wheel or a partial sieve to skip obvious composites.



                    See Cramér's conjecture for a thought on how long this would take. In practice this is quite efficient, with inputs of thousands of digits being straightforward to calculate. You can look up the concept of "merits" for gaps. On average you'll find the next prime about $log n$ away. For large inputs, I found sieving to a distance of $30 log n$ (30 merits) was plenty to get excellent performance with exceptionally few gaps that need to look farther.



                    Knowing the previous prime hasn't really given us any special information though, as Gerry pointed out.







                  share|cite|improve this answer











                  $endgroup$



                  You're got what looks like two questions.




                  1. The time complexity of the nth prime. In practice it is $Obig(fracn^2/3log^2nbig)$ using fast prime count algorithms. In theory this could be lowered to something on the order of $O(n^1/2)$. See:



                    • Most efficient algorithm for nth prime, deterministic and probabilistic?

                    • https://cs.stackexchange.com/questions/10683/what-is-the-time-complexity-of-generating-n-th-prime-number

                    • primesieve README



                  2. Does knowing P(n-1) allow one to quickly find P(n)? Yes, in the sense that we have reduced the problem to a single nextprime call. Once beyond trivial sizes, this is just a loop calling isprime. One might want to use a wheel or a partial sieve to skip obvious composites.



                    See Cramér's conjecture for a thought on how long this would take. In practice this is quite efficient, with inputs of thousands of digits being straightforward to calculate. You can look up the concept of "merits" for gaps. On average you'll find the next prime about $log n$ away. For large inputs, I found sieving to a distance of $30 log n$ (30 merits) was plenty to get excellent performance with exceptionally few gaps that need to look farther.



                    Knowing the previous prime hasn't really given us any special information though, as Gerry pointed out.








                  share|cite|improve this answer














                  share|cite|improve this answer



                  share|cite|improve this answer








                  edited yesterday

























                  answered Jan 8 at 1:01









                  DanaJDanaJ

                  2,38911017




                  2,38911017





















                      -2












                      $begingroup$

                      A good method for the operation of a prime number program is to output only the primes between an upper-bound and the upper-bound - k . Then the program just appears to be jumping from one section of a list to the other on each computation. Of course required consecutive primes are obviously found within the range of the output.



                      Here is my previous post:



                      Odd numbers can be wheeled in multiplications to output only odd composite numbers. Then the odd numbers that are not output are the prime numbers.



                      Now each inner loop can stop at a multiplication that reaches the value of an upper-bound and the outer loop can stop at the square root of the upper-bound.



                      Furthermore the loops from the number 11 can increment with 2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10 ... as continuing and repeating. That's a big performance gain because multiples of 3, 5, and 7 are removed from the sequence of odd numbers.



                      A prime number application really works best when outputting prime numbers between an upper bound and the upper bound - k. Then the application appears to be just scrolling sections (or jumping to sections) of a list on each computation. And in this case the loop increments are really only needed on the outer loop because a single division operation jumps over unneeded sections of the inner loop. Of course, array subscript locations can work with translations such that the same array can handle any of the segmented computations and then not use very much memory.






                      share|cite|improve this answer











                      $endgroup$








                      • 4




                        $begingroup$
                        My only comment is: "Huh?"
                        $endgroup$
                        – Matt Samuel
                        Jan 6 at 23:41










                      • $begingroup$
                        Description of a computational computer program is an algorithm.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:25










                      • $begingroup$
                        I don’t understand any of this, but it sounds like exhaustive search which doesn’t help OP. Whatever it is, it’s not an answer.
                        $endgroup$
                        – Randall
                        Jan 7 at 0:28










                      • $begingroup$
                        The OP doesn't need the primes to be counted but only needs the next prime after a counted prime. The algorithm does work in the situation. But odd composite numbers are output to an array and odd positions in the array that don't receive an output represent the prime numbers. Sections of prime numbers less than the upper-bound - k are jumped over in the computation.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:40
















                      -2












                      $begingroup$

                      A good method for the operation of a prime number program is to output only the primes between an upper-bound and the upper-bound - k . Then the program just appears to be jumping from one section of a list to the other on each computation. Of course required consecutive primes are obviously found within the range of the output.



                      Here is my previous post:



                      Odd numbers can be wheeled in multiplications to output only odd composite numbers. Then the odd numbers that are not output are the prime numbers.



                      Now each inner loop can stop at a multiplication that reaches the value of an upper-bound and the outer loop can stop at the square root of the upper-bound.



                      Furthermore the loops from the number 11 can increment with 2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10 ... as continuing and repeating. That's a big performance gain because multiples of 3, 5, and 7 are removed from the sequence of odd numbers.



                      A prime number application really works best when outputting prime numbers between an upper bound and the upper bound - k. Then the application appears to be just scrolling sections (or jumping to sections) of a list on each computation. And in this case the loop increments are really only needed on the outer loop because a single division operation jumps over unneeded sections of the inner loop. Of course, array subscript locations can work with translations such that the same array can handle any of the segmented computations and then not use very much memory.






                      share|cite|improve this answer











                      $endgroup$








                      • 4




                        $begingroup$
                        My only comment is: "Huh?"
                        $endgroup$
                        – Matt Samuel
                        Jan 6 at 23:41










                      • $begingroup$
                        Description of a computational computer program is an algorithm.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:25










                      • $begingroup$
                        I don’t understand any of this, but it sounds like exhaustive search which doesn’t help OP. Whatever it is, it’s not an answer.
                        $endgroup$
                        – Randall
                        Jan 7 at 0:28










                      • $begingroup$
                        The OP doesn't need the primes to be counted but only needs the next prime after a counted prime. The algorithm does work in the situation. But odd composite numbers are output to an array and odd positions in the array that don't receive an output represent the prime numbers. Sections of prime numbers less than the upper-bound - k are jumped over in the computation.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:40














                      -2












                      -2








                      -2





                      $begingroup$

                      A good method for the operation of a prime number program is to output only the primes between an upper-bound and the upper-bound - k . Then the program just appears to be jumping from one section of a list to the other on each computation. Of course required consecutive primes are obviously found within the range of the output.



                      Here is my previous post:



                      Odd numbers can be wheeled in multiplications to output only odd composite numbers. Then the odd numbers that are not output are the prime numbers.



                      Now each inner loop can stop at a multiplication that reaches the value of an upper-bound and the outer loop can stop at the square root of the upper-bound.



                      Furthermore the loops from the number 11 can increment with 2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10 ... as continuing and repeating. That's a big performance gain because multiples of 3, 5, and 7 are removed from the sequence of odd numbers.



                      A prime number application really works best when outputting prime numbers between an upper bound and the upper bound - k. Then the application appears to be just scrolling sections (or jumping to sections) of a list on each computation. And in this case the loop increments are really only needed on the outer loop because a single division operation jumps over unneeded sections of the inner loop. Of course, array subscript locations can work with translations such that the same array can handle any of the segmented computations and then not use very much memory.






                      share|cite|improve this answer











                      $endgroup$



                      A good method for the operation of a prime number program is to output only the primes between an upper-bound and the upper-bound - k . Then the program just appears to be jumping from one section of a list to the other on each computation. Of course required consecutive primes are obviously found within the range of the output.



                      Here is my previous post:



                      Odd numbers can be wheeled in multiplications to output only odd composite numbers. Then the odd numbers that are not output are the prime numbers.



                      Now each inner loop can stop at a multiplication that reaches the value of an upper-bound and the outer loop can stop at the square root of the upper-bound.



                      Furthermore the loops from the number 11 can increment with 2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2,4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10 ... as continuing and repeating. That's a big performance gain because multiples of 3, 5, and 7 are removed from the sequence of odd numbers.



                      A prime number application really works best when outputting prime numbers between an upper bound and the upper bound - k. Then the application appears to be just scrolling sections (or jumping to sections) of a list on each computation. And in this case the loop increments are really only needed on the outer loop because a single division operation jumps over unneeded sections of the inner loop. Of course, array subscript locations can work with translations such that the same array can handle any of the segmented computations and then not use very much memory.







                      share|cite|improve this answer














                      share|cite|improve this answer



                      share|cite|improve this answer








                      edited Jan 6 at 23:28

























                      answered Jan 6 at 23:23









                      S SpringS Spring

                      1723




                      1723







                      • 4




                        $begingroup$
                        My only comment is: "Huh?"
                        $endgroup$
                        – Matt Samuel
                        Jan 6 at 23:41










                      • $begingroup$
                        Description of a computational computer program is an algorithm.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:25










                      • $begingroup$
                        I don’t understand any of this, but it sounds like exhaustive search which doesn’t help OP. Whatever it is, it’s not an answer.
                        $endgroup$
                        – Randall
                        Jan 7 at 0:28










                      • $begingroup$
                        The OP doesn't need the primes to be counted but only needs the next prime after a counted prime. The algorithm does work in the situation. But odd composite numbers are output to an array and odd positions in the array that don't receive an output represent the prime numbers. Sections of prime numbers less than the upper-bound - k are jumped over in the computation.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:40













                      • 4




                        $begingroup$
                        My only comment is: "Huh?"
                        $endgroup$
                        – Matt Samuel
                        Jan 6 at 23:41










                      • $begingroup$
                        Description of a computational computer program is an algorithm.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:25










                      • $begingroup$
                        I don’t understand any of this, but it sounds like exhaustive search which doesn’t help OP. Whatever it is, it’s not an answer.
                        $endgroup$
                        – Randall
                        Jan 7 at 0:28










                      • $begingroup$
                        The OP doesn't need the primes to be counted but only needs the next prime after a counted prime. The algorithm does work in the situation. But odd composite numbers are output to an array and odd positions in the array that don't receive an output represent the prime numbers. Sections of prime numbers less than the upper-bound - k are jumped over in the computation.
                        $endgroup$
                        – S Spring
                        Jan 7 at 0:40








                      4




                      4




                      $begingroup$
                      My only comment is: "Huh?"
                      $endgroup$
                      – Matt Samuel
                      Jan 6 at 23:41




                      $begingroup$
                      My only comment is: "Huh?"
                      $endgroup$
                      – Matt Samuel
                      Jan 6 at 23:41












                      $begingroup$
                      Description of a computational computer program is an algorithm.
                      $endgroup$
                      – S Spring
                      Jan 7 at 0:25




                      $begingroup$
                      Description of a computational computer program is an algorithm.
                      $endgroup$
                      – S Spring
                      Jan 7 at 0:25












                      $begingroup$
                      I don’t understand any of this, but it sounds like exhaustive search which doesn’t help OP. Whatever it is, it’s not an answer.
                      $endgroup$
                      – Randall
                      Jan 7 at 0:28




                      $begingroup$
                      I don’t understand any of this, but it sounds like exhaustive search which doesn’t help OP. Whatever it is, it’s not an answer.
                      $endgroup$
                      – Randall
                      Jan 7 at 0:28












                      $begingroup$
                      The OP doesn't need the primes to be counted but only needs the next prime after a counted prime. The algorithm does work in the situation. But odd composite numbers are output to an array and odd positions in the array that don't receive an output represent the prime numbers. Sections of prime numbers less than the upper-bound - k are jumped over in the computation.
                      $endgroup$
                      – S Spring
                      Jan 7 at 0:40





                      $begingroup$
                      The OP doesn't need the primes to be counted but only needs the next prime after a counted prime. The algorithm does work in the situation. But odd composite numbers are output to an array and odd positions in the array that don't receive an output represent the prime numbers. Sections of prime numbers less than the upper-bound - k are jumped over in the computation.
                      $endgroup$
                      – S Spring
                      Jan 7 at 0:40


















                      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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3064501%2fis-there-a-way-to-determine-exactly-the-difference-between-nth-n1th-pri%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

                      Moe incest case Sentencing See also References Navigation menu"'Australian Josef Fritzl' fathered four children by daughter""Small town recoils in horror at 'Australian Fritzl' incest case""Victorian rape allegations echo Fritzl case - Just In (Australian Broadcasting Corporation)""Incest father jailed for 22 years""'Australian Fritzl' sentenced to 22 years in prison for abusing daughter for three decades""RSJ v The Queen"

                      Who is our nearest planetary neighbor, on average?Santa Claus flies to the South PoleSeven Spheres of Unequal Mass, a weighing problem with a twistDescribe a large integerFast Mental Calculation of $7.5^7$Math in Space (without the help of celebrities)Find the value of $bigstar$: Puzzle 8 - InequalityWho drinks beer while running anyway?A Crucial DeliveryRanking And AverageHow long will my money last at roulette?

                      Daza language Contents Vocabulary Phonology References External links Navigation menudaza1242Daza"Dazaga"eeee178086576