Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Algorithms
  4. TIL...... [modified]

TIL...... [modified]

Scheduled Pinned Locked Moved Algorithms
question
31 Posts 13 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N NeverHeardOfMe

    ...an extraordinary fact - probably known to half of you, but nevertheless I thought I'd share it. It's not an alogorithm, but never mind! The square of any prime number >= 5 can be expressed as 1 + a multiple of 24 or If p is prime, then p ^ 2 = 1 + 24 * n, for some n Don't know about you, but I think that's quite amazing. Why is it true at all, and given that it is, where does 24 come from?! (Pity it's not 42 really!) [edit] When I ask "where does 24 come from?" I am not asking for a mathermatical proof - I can look that up myself. It's more just a metaphysical musing...)

    modified on Thursday, November 4, 2010 6:37 AM

    R Offline
    R Offline
    Radhakrishnan G
    wrote on last edited by
    #2

    what is that "n" it is 1 for p = 5??

    N 1 Reply Last reply
    0
    • R Radhakrishnan G

      what is that "n" it is 1 for p = 5??

      N Offline
      N Offline
      NeverHeardOfMe
      wrote on last edited by
      #3

      Yes, for p=5, n=1 p=7, n=2 p=11, n=5 p=13, n=7 If you can work out a forumla that spits out each value of n that produces the "next" prime, you'll be able to retire early :)

      1 Reply Last reply
      0
      • N NeverHeardOfMe

        ...an extraordinary fact - probably known to half of you, but nevertheless I thought I'd share it. It's not an alogorithm, but never mind! The square of any prime number >= 5 can be expressed as 1 + a multiple of 24 or If p is prime, then p ^ 2 = 1 + 24 * n, for some n Don't know about you, but I think that's quite amazing. Why is it true at all, and given that it is, where does 24 come from?! (Pity it's not 42 really!) [edit] When I ask "where does 24 come from?" I am not asking for a mathermatical proof - I can look that up myself. It's more just a metaphysical musing...)

        modified on Thursday, November 4, 2010 6:37 AM

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        Try

        p ^ 2 = 1 + 24 * (p - 6)

        Just say 'NO' to evaluated arguments for diadic functions! Ash

        N R 2 Replies Last reply
        0
        • L Lost User

          Try

          p ^ 2 = 1 + 24 * (p - 6)

          Just say 'NO' to evaluated arguments for diadic functions! Ash

          N Offline
          N Offline
          NeverHeardOfMe
          wrote on last edited by
          #5

          OK... p^2 - 24*p + 143 = 0 So..?

          L L 2 Replies Last reply
          0
          • N NeverHeardOfMe

            OK... p^2 - 24*p + 143 = 0 So..?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            :confused:

            Just say 'NO' to evaluated arguments for diadic functions! Ash

            N 1 Reply Last reply
            0
            • L Lost User

              :confused:

              Just say 'NO' to evaluated arguments for diadic functions! Ash

              N Offline
              N Offline
              NeverHeardOfMe
              wrote on last edited by
              #7

              Me :confused: too - ome of us is being a bit dumb here (most likely me...) I just re-wrote the equation you posted... what does it prove? Is there a typo in it (yours)?

              L 1 Reply Last reply
              0
              • N NeverHeardOfMe

                OK... p^2 - 24*p + 143 = 0 So..?

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #8

                a quadratic equation like that has at most two solutions, so it is hardly a way to discover lots of primes. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                modified on Thursday, November 4, 2010 12:05 PM

                N 1 Reply Last reply
                0
                • N NeverHeardOfMe

                  ...an extraordinary fact - probably known to half of you, but nevertheless I thought I'd share it. It's not an alogorithm, but never mind! The square of any prime number >= 5 can be expressed as 1 + a multiple of 24 or If p is prime, then p ^ 2 = 1 + 24 * n, for some n Don't know about you, but I think that's quite amazing. Why is it true at all, and given that it is, where does 24 come from?! (Pity it's not 42 really!) [edit] When I ask "where does 24 come from?" I am not asking for a mathermatical proof - I can look that up myself. It's more just a metaphysical musing...)

                  modified on Thursday, November 4, 2010 6:37 AM

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #9

                  that is correct, even when n needs to be 1/8 for p=2. :-D

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                  N 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    a quadratic equation like that has at most two solutions, so it is hardly a way to discover lots of primes. :)

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                    modified on Thursday, November 4, 2010 12:05 PM

                    N Offline
                    N Offline
                    NeverHeardOfMe
                    wrote on last edited by
                    #10

                    We have a saying round here: "Don't tell I, tell 'e"... especially as that particular one doesn't even have any (real) solutions at all!

                    L 1 Reply Last reply
                    0
                    • L Luc Pattyn

                      that is correct, even when n needs to be 1/8 for p=2. :-D

                      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                      N Offline
                      N Offline
                      NeverHeardOfMe
                      wrote on last edited by
                      #11

                      Actually, that's QI.. it also "works" for p=3 (n=1/3) - so in fact, the *only* value of p for which n is neither an integer nor a proper fraction is 4.[edit] OOPS what an idiot! since when was 4 a prime! :-O

                      1 Reply Last reply
                      0
                      • N NeverHeardOfMe

                        Me :confused: too - ome of us is being a bit dumb here (most likely me...) I just re-wrote the equation you posted... what does it prove? Is there a typo in it (yours)?

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        No typo as far as I am aware. I just thought you wanted to know what was the value of 'n' in your original question.

                        Just say 'NO' to evaluated arguments for diadic functions! Ash

                        N 1 Reply Last reply
                        0
                        • N NeverHeardOfMe

                          We have a saying round here: "Don't tell I, tell 'e"... especially as that particular one doesn't even have any (real) solutions at all!

                          L Offline
                          L Offline
                          Luc Pattyn
                          wrote on last edited by
                          #13

                          you'll have more luck with

                          x2 + x + 41

                          for natural values of x. :)

                          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                          N 1 Reply Last reply
                          0
                          • L Lost User

                            No typo as far as I am aware. I just thought you wanted to know what was the value of 'n' in your original question.

                            Just say 'NO' to evaluated arguments for diadic functions! Ash

                            N Offline
                            N Offline
                            NeverHeardOfMe
                            wrote on last edited by
                            #14

                            Ah, got you - except that it doesn't work for all values of p p=5, n=1 != p-6 p=7, n=2 != p-6 p=11, n=5 ok p=13, n=7 ok p=17, n=12 != p-6 ...

                            1 Reply Last reply
                            0
                            • L Luc Pattyn

                              you'll have more luck with

                              x2 + x + 41

                              for natural values of x. :)

                              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                              N Offline
                              N Offline
                              NeverHeardOfMe
                              wrote on last edited by
                              #15

                              Now you're just confusing me....

                              1 Reply Last reply
                              0
                              • N NeverHeardOfMe

                                ...an extraordinary fact - probably known to half of you, but nevertheless I thought I'd share it. It's not an alogorithm, but never mind! The square of any prime number >= 5 can be expressed as 1 + a multiple of 24 or If p is prime, then p ^ 2 = 1 + 24 * n, for some n Don't know about you, but I think that's quite amazing. Why is it true at all, and given that it is, where does 24 come from?! (Pity it's not 42 really!) [edit] When I ask "where does 24 come from?" I am not asking for a mathermatical proof - I can look that up myself. It's more just a metaphysical musing...)

                                modified on Thursday, November 4, 2010 6:37 AM

                                _ Offline
                                _ Offline
                                _Erik_
                                wrote on last edited by
                                #16

                                Well, I know you are not asking for a mathematical proof, but like I am much better at maths than metaphisics... Where does 24 come from? Since p is prime and greater than 5, p cannot be an even number. So: p2-1=(p-1)*(p+1). Like p is odd, both (p-1) and (p+1) are even, so we can say: p2-1=2a*2b=4ab. Like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 4, so 2a is multiple of 4 or 2b is multiple of 4, so we can express this like: p2-1=4a*2c=8ac or p2-1=4b*2d=8bd I will examine just one of these two cases becouse they are symmetrical. Now, like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 3, so: p2-1=8a*3d=24ad or p2-1=8c*3e=24ce And there it is.

                                N M 2 Replies Last reply
                                0
                                • _ _Erik_

                                  Well, I know you are not asking for a mathematical proof, but like I am much better at maths than metaphisics... Where does 24 come from? Since p is prime and greater than 5, p cannot be an even number. So: p2-1=(p-1)*(p+1). Like p is odd, both (p-1) and (p+1) are even, so we can say: p2-1=2a*2b=4ab. Like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 4, so 2a is multiple of 4 or 2b is multiple of 4, so we can express this like: p2-1=4a*2c=8ac or p2-1=4b*2d=8bd I will examine just one of these two cases becouse they are symmetrical. Now, like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 3, so: p2-1=8a*3d=24ad or p2-1=8c*3e=24ce And there it is.

                                  N Offline
                                  N Offline
                                  NeverHeardOfMe
                                  wrote on last edited by
                                  #17

                                  You haven't explained the last step correctly, and the statement

                                  _Erik_ wrote:

                                  Now, like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 3

                                  is wrong.

                                  _ 1 Reply Last reply
                                  0
                                  • N NeverHeardOfMe

                                    You haven't explained the last step correctly, and the statement

                                    _Erik_ wrote:

                                    Now, like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 3

                                    is wrong.

                                    _ Offline
                                    _ Offline
                                    _Erik_
                                    wrote on last edited by
                                    #18

                                    It is not wrong, becouse p is a prime number, what means: if p mod 3 = 1 then (p-1) mod 3=0, so (p-1) is multiple of 3. if p mod 3 = 2 then (p+1) mod 3=0, so (p+1) is multiple of 3. if p mod 3 = 0 then p would not be prime and we would not be following our premise

                                    N 1 Reply Last reply
                                    0
                                    • _ _Erik_

                                      It is not wrong, becouse p is a prime number, what means: if p mod 3 = 1 then (p-1) mod 3=0, so (p-1) is multiple of 3. if p mod 3 = 2 then (p+1) mod 3=0, so (p+1) is multiple of 3. if p mod 3 = 0 then p would not be prime and we would not be following our premise

                                      N Offline
                                      N Offline
                                      NeverHeardOfMe
                                      wrote on last edited by
                                      #19

                                      Yes, sorry - I was forgetting that p is prime! Time to knock off for the day I think...

                                      1 Reply Last reply
                                      0
                                      • _ _Erik_

                                        Well, I know you are not asking for a mathematical proof, but like I am much better at maths than metaphisics... Where does 24 come from? Since p is prime and greater than 5, p cannot be an even number. So: p2-1=(p-1)*(p+1). Like p is odd, both (p-1) and (p+1) are even, so we can say: p2-1=2a*2b=4ab. Like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 4, so 2a is multiple of 4 or 2b is multiple of 4, so we can express this like: p2-1=4a*2c=8ac or p2-1=4b*2d=8bd I will examine just one of these two cases becouse they are symmetrical. Now, like (p-1) and (p+1) are two consecutive even numbers, one of them must be multiple of 3, so: p2-1=8a*3d=24ad or p2-1=8c*3e=24ce And there it is.

                                        M Offline
                                        M Offline
                                        MarkLoboo
                                        wrote on last edited by
                                        #20

                                        3 cheers !!:thumbsup:

                                        All are born right-handed. Only gifted few overcome it. There's NO excuse for not commenting your code.

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          Try

                                          p ^ 2 = 1 + 24 * (p - 6)

                                          Just say 'NO' to evaluated arguments for diadic functions! Ash

                                          R Offline
                                          R Offline
                                          redbones
                                          wrote on last edited by
                                          #21

                                          actually that's not correct; when p=7 then by your formula we would have 49=1+24*1 = 25

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups