divisible by

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kris mynn
    New Member
    • Oct 2007
    • 5

    #1

    divisible by

    i need help on how to write a code that will print numbers 1-100,0000 and the #s are divisible by 7,11, and 13. I was told to start with 1001/7, 1001/11, 1001/13. I just don't get this and need it urgently.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by kris mynn
    i need help on how to write a code that will print numbers 1-100,0000 and the #s are divisible by 7,11, and 13. I was told to start with 1001/7, 1001/11, 1001/13. I just don't get this and need it urgently.
    How much you tried show me that code and let me know where you stuck.

    Kind regards,
    Dmjpro.

    Comment

    • kris mynn
      New Member
      • Oct 2007
      • 5

      #3
      i'm not even sure where to start

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by kris mynn
        i'm not even sure where to start
        First let me know how long you are working with Java?
        Have a close look on it.

        [code=java]
        for(int i=1;i<=100,0000 ;i++)
        if(i%7==0||i%11 ==0||i%13==0) System.out.prin tln(i);
        [/code]

        Good Luck!
        And never come with these type of easy problems.

        Kind regards,
        Dmjpro.

        Comment

        • kris mynn
          New Member
          • Oct 2007
          • 5

          #5
          First week of java for me. Thanks for the help.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by dmjpro
            First let me know how long you are working with Java?
            Have a close look on it.

            [code=java]
            for(int i=1;i<=100,0000 ;i++)
            if(i%7==0||i%11 ==0||i%13==0) System.out.prin tln(i);
            [/code]

            Good Luck!
            And never come with these type of easy problems.

            Kind regards,
            Dmjpro.
            That won't compile

            Comment

            • kris mynn
              New Member
              • Oct 2007
              • 5

              #7
              I have not tested it yet. Why do you say it will not compile?

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by kris mynn
                i need help on how to write a code that will print numbers 1-100,0000 and the #s are divisible by 7,11, and 13. I was told to start with 1001/7, 1001/11, 1001/13. I just don't get this and need it urgently.
                Well, the smallest number that is divisable by 7, 11, and 13 is 7x11x13 == 1001
                because all of 7, 11, and 13 are prime numbers.

                kind regards,

                Jos

                Comment

                • kris mynn
                  New Member
                  • Oct 2007
                  • 5

                  #9
                  In the output data i was told i should see 1111 and 123123... So would it be 1001/7, 1001/11, 1001/13? I don't know how that would be coded.

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by kris mynn
                    In the output data i was told i should see 1111 and 123123... So would it be 1001/7, 1001/11, 1001/13? I don't know how that would be coded.
                    No, a number can only be divided by 1001 if it can be divided by 7, 11, and 13,
                    so you should only check if x/1001 doesn't have a remainder. Don't bother about
                    7, 11 and 13 individually, i.e. simply check if the remainder of x and 1001 is 0.

                    kind regards,

                    Jos

                    Comment

                    Working...