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
  1. Home
  2. General Programming
  3. Algorithms
  4. Hardcore Maths Question

Hardcore Maths Question

Scheduled Pinned Locked Moved Algorithms
questionasp-netcombusiness
46 Posts 11 Posters 0 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.
  • J JenovaProject

    10! - 1 = 3628799. Its 1 less than a multiple of 1, 2, 3 ... 10.

    U Offline
    U Offline
    User 12346520
    wrote on last edited by
    #27

    thanks: https://movied.org

    1 Reply Last reply
    0
    • R Raj Lal

      its the LCM of all the numbers (2520) - 1

      Omit Needless Words - Strunk, William, Jr.


      Online Project Management
      Universal DBA | Ajax Rating | ExplorerTree

      U Offline
      U Offline
      User 12346520
      wrote on last edited by
      #28

      thanks: https://movied.org

      1 Reply Last reply
      0
      • L leppie

        Some other interesting and useless observations:

        1*2*3*4*5*6*7*8*9 is divisible by 2520 = 144
        2520 is divisible by 2 * 3 * 5 * 7 = 12 (product of prime 1 - 9)
        4 * 6 * 8 * 9 is divisible by 144 = 12 (product of 'non' prime 1 - 9)

        :doh:

        **

        xacc.ide-0.2.0.50 - now with partial MSBuild support!

        **

        U Offline
        U Offline
        User 12346520
        wrote on last edited by
        #29

        thanks: https://movied.org

        1 Reply Last reply
        0
        • L leppie

          Jon Sagara wrote:

          N(n) = 2519 + (n - 1)*(2520)

          N(n) = (n * 2520) - 1 = 2520n - 1

          **

          xacc.ide-0.2.0.50 - now with partial MSBuild support!

          **

          U Offline
          U Offline
          User 12346520
          wrote on last edited by
          #30

          thanks: https://movied.org

          1 Reply Last reply
          0
          • J Jon Sagara

            N(1) = 2519 N(2) = 2519 + 2520 = 5039 N(3) = 2519 + 2520 + 2520 = 7559 N(4) = 2519 + 2520 + 2520 + 2520 = 10079 ... N(n) = 2519 + (n - 1)*(2520) No idea what the heck it means, though. Care to enlighten us mathematically-challenged folks?

            Jon Sagara When I grow up, I'm changing my name to Joe Kickass! My Site | My Blog | My Articles

            U Offline
            U Offline
            User 12346520
            wrote on last edited by
            #31

            thanks: https://movied.org

            1 Reply Last reply
            0
            • P Paul Conrad

              Judah Himango wrote:

              Voila, cool little WinForms program that solves it. :cool:

              That's cool. Mine is just a plain boring console app :->


              I'd like to help but I am too lazy to Google it for you.

              U Offline
              U Offline
              User 12346520
              wrote on last edited by
              #32

              thanks: https://movied.org

              1 Reply Last reply
              0
              • J Judah Gabriel Himango

                Quartz... wrote:

                It's the journey, not the destination

                Very true. I actually had fun writing a little piece of code to solve it, though, so it was the journey even still. :) I added some more code that added each match to a list box on a Windows Form. Then, after seeing how it froze up the UI, I did it on a background thread. Still, the UI thread would get flooded with matches, almost preventing it from painting, so I further chagned the code to only update during app idle. Voila, cool little WinForms program that solves it. :cool:

                Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

                U Offline
                U Offline
                User 12346520
                wrote on last edited by
                #33

                thanks: https://movied.org

                1 Reply Last reply
                0
                • R Raj Lal

                  Judah Himango wrote:

                  I kind of cheated though

                  well thats ok , and of course there are more numbers but the fun is when you deduce how to do it It's the journey, not the destination

                  Omit Needless Words - Strunk, William, Jr.


                  Online Project Management
                  Universal DBA | Ajax Rating | ExplorerTree

                  U Offline
                  U Offline
                  User 12346520
                  wrote on last edited by
                  #34

                  thanks: https://movied.org

                  1 Reply Last reply
                  0
                  • P Paul Conrad

                    leppie wrote:

                    So there are more than one of these. I wonder if its some kind of series...

                    Take a look at the modification of Judah's code that I posted. Your number is one of the numbers that come up :)


                    I'd like to help but I am too lazy to Google it for you.

                    U Offline
                    U Offline
                    User 12346520
                    wrote on last edited by
                    #35

                    thanks: https://movied.org

                    1 Reply Last reply
                    0
                    • P Paul Conrad

                      Judah Himango wrote:

                      It appears to be every 2520.

                      It is. Modifying the your code that I modified and posted, shows this to be true :)


                      I'd like to help but I am too lazy to Google it for you.

                      U Offline
                      U Offline
                      User 12346520
                      wrote on last edited by
                      #36

                      thanks: https://movied.org

                      1 Reply Last reply
                      0
                      • J Judah Gabriel Himango

                        leppie wrote:

                        I wonder if its some kind of series...

                        It appears to be every 2520.

                        Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

                        U Offline
                        U Offline
                        User 12346520
                        wrote on last edited by
                        #37

                        thanks: https://movied.org

                        1 Reply Last reply
                        0
                        • R Raj Lal

                          yes thats true there are many , but if you think it might take a day to get the solution , without any computer help, but its worth

                          Omit Needless Words - Strunk, William, Jr.


                          Online Project Management
                          Universal DBA | Ajax Rating | ExplorerTree

                          U Offline
                          U Offline
                          User 12346520
                          wrote on last edited by
                          #38

                          thanks: https://movied.org

                          1 Reply Last reply
                          0
                          • P Paul Conrad

                            There was a question of if there were more number, yes, there are. Here is a modification of your code that shows others :)

                            #include using namespace std;

                            int main()
                            {
                            int start = 1;
                            int divisor = 10;
                            while ( start <1000000 ) // Or whatevery you want in signed 32-bit range
                            {
                            while (divisor >= 2)
                            {
                            if (start % divisor == divisor - 1)
                            {
                            divisor--;
                            }
                            else
                            {
                            start++;
                            divisor = 10;
                            }
                            }

                                cout<
                            
                            U Offline
                            U Offline
                            User 12346520
                            wrote on last edited by
                            #39

                            thanks: https://movied.org

                            1 Reply Last reply
                            0
                            • J Judah Gabriel Himango

                              yeah yeah :) Hey, I worked for it at least. :) *edit* oooh, misunderstood you there leppie. I though you were chiding me for solving it with code rather than brain. :) Yes, there are other numbers, it appears every 2520 iteration matches the criteria.

                              Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

                              U Offline
                              U Offline
                              User 12346520
                              wrote on last edited by
                              #40

                              thanks: https://movied.org

                              1 Reply Last reply
                              0
                              • L leppie

                                Judah Himango wrote:

                                I kind of cheated.

                                He did say "find a number" :) So there are more than one of these. I wonder if its some kind of series...

                                **

                                xacc.ide-0.2.0.50 - now with partial MSBuild support!

                                **

                                U Offline
                                U Offline
                                User 12346520
                                wrote on last edited by
                                #41

                                thanks: https://movied.org

                                1 Reply Last reply
                                0
                                • J Judah Gabriel Himango

                                  Provided I've understood the question correctly, I think I've solved it. I kind of cheated though; I wrote a C# program that solves this:

                                          int start = 1;
                                          int divisor = 10;
                                          while (divisor >= 2)
                                          {
                                              if (start % divisor == divisor - 1)
                                              {
                                                  divisor--;
                                              }
                                              else
                                              {
                                                  start++;
                                                  divisor = 10;
                                              }
                                          }
                                  

                                  Soon as that loop exits, you've got your number, which happens to be 2519.

                                  U Offline
                                  U Offline
                                  User 12346520
                                  wrote on last edited by
                                  #42

                                  thanks: https://movied.org

                                  1 Reply Last reply
                                  0
                                  • L leppie

                                    2701439 last 4 digits by deduction, rest trial and error guess with 3/9 rule. :)

                                    **

                                    xacc.ide-0.2.0.50 - now with partial MSBuild support!

                                    **

                                    U Offline
                                    U Offline
                                    User 12346520
                                    wrote on last edited by
                                    #43

                                    thanks: https://movied.org

                                    1 Reply Last reply
                                    0
                                    • L leppie

                                      Here's a wild guess: 123456789 ? [edit] ok I got the 9 bit :p [edit] -- modified at 18:37 Wednesday 26th July, 2006

                                      U Offline
                                      U Offline
                                      User 12346520
                                      wrote on last edited by
                                      #44

                                      thanks: https://movied.org

                                      1 Reply Last reply
                                      0
                                      • A Andrew Bleakley

                                        It's not a mexican is it ?

                                        U Offline
                                        U Offline
                                        User 12346520
                                        wrote on last edited by
                                        #45

                                        thanks: https://movied.org

                                        1 Reply Last reply
                                        0
                                        • R Raj Lal

                                          Ok lets me be the first to ask a maths question Find a number which 1. divided by 10 gives a remainder 9 2. divided by 9 gives remainder 8 --- --- so on till divided by 2 gives a remainder 1 Any one ?

                                          Omit Needless Words - Strunk, William, Jr.


                                          Online Project Management
                                          Universal DBA | Ajax Rating | ExplorerTree

                                          U Offline
                                          U Offline
                                          User 12346520
                                          wrote on last edited by
                                          #46

                                          thanks: https://movied.org

                                          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