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.
  • 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

    B Offline
    B Offline
    Bassam Abdul Baki
    wrote on last edited by
    #21

    x = (i - 1) (mod i), 2 ≤ i ≤ 10. Thus, x = LCM(2, 3, 4, 5, 6, 7, 8, 9, 10) * k + LCM(2, 3, 4, 5, 6, 7, 8, 9, 10) - 1 LCM(2, 3, 4, 5, 6, 7, 8, 9, 10) = LCM(5, 7, 8, 9) = 23.32.5.7 = 2520. Thus, x = 2520k + 2519. min(x) = 2519. I had to redo it since I did it backwards.


    "People who want to share their religious views with you almost never want you to share yours with them." - Anonymous Web - Blog - RSS - Math - LinkedIn

    Last modified: Thursday, July 27, 2006 12:08:26 PM --

    U 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

      K Offline
      K Offline
      Kacee Giger
      wrote on last edited by
      #22

      I know I'm a little late (and a valid solution has already been given), but no real explanation has been made. You first need to find a number that is a multiple of all these multiples (10 * 9, 9 * 8, etc), then one less than that will give the proper remainders. So, to find the least common multiple, first break these into primes: 10 * 9 = 2 * 3 * 3 * 5, 9 * 8 = 2 * 2 * 2 * 3 * 3, 8 * 7 = 2 * 2 * 2 * 7, etc. Take out what is unique for each to get 2 * 2 * 2 * 3 * 3 * 5 * 7 = 2520. So, one answer (though you already know) to the original problem is 2519.

      U 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

        R Offline
        R Offline
        Raj Lal
        wrote on last edited by
        #23

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

        Omit Needless Words - Strunk, William, Jr.


        Online Project Management
        Universal DBA | Ajax Rating | ExplorerTree

        U 1 Reply Last reply
        0
        • K Kacee Giger

          I know I'm a little late (and a valid solution has already been given), but no real explanation has been made. You first need to find a number that is a multiple of all these multiples (10 * 9, 9 * 8, etc), then one less than that will give the proper remainders. So, to find the least common multiple, first break these into primes: 10 * 9 = 2 * 3 * 3 * 5, 9 * 8 = 2 * 2 * 2 * 3 * 3, 8 * 7 = 2 * 2 * 2 * 7, etc. Take out what is unique for each to get 2 * 2 * 2 * 3 * 3 * 5 * 7 = 2520. So, one answer (though you already know) to the original problem is 2519.

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

          thanks: https://movied.org

          1 Reply Last reply
          0
          • B Bassam Abdul Baki

            x = (i - 1) (mod i), 2 ≤ i ≤ 10. Thus, x = LCM(2, 3, 4, 5, 6, 7, 8, 9, 10) * k + LCM(2, 3, 4, 5, 6, 7, 8, 9, 10) - 1 LCM(2, 3, 4, 5, 6, 7, 8, 9, 10) = LCM(5, 7, 8, 9) = 23.32.5.7 = 2520. Thus, x = 2520k + 2519. min(x) = 2519. I had to redo it since I did it backwards.


            "People who want to share their religious views with you almost never want you to share yours with them." - Anonymous Web - Blog - RSS - Math - LinkedIn

            Last modified: Thursday, July 27, 2006 12:08:26 PM --

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

            thanks: https://movied.org

            1 Reply Last reply
            0
            • I Ingo

              ((3628799 + 1) / 10) / (2 * 3 * 4 * 6) + (9 - 7 + 8 - 10) + 1 = 2519. ;)

              ------------------------------ PROST Roleplaying Game War doesn't determine who's right. War determines who's left.

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

              thanks: https://movied.org

              1 Reply Last reply
              0
              • 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
                                          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