Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Trying to make a largest divisor solver.

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trying to make a largest divisor solver.

    Write a method largestDivisor that takes an integer argument and returns the largest positive integer which is less than the argument that divides the argument. (For example, 10 is the largest divisor of 20.) You may assume that the argument is positive. If the argument is 1, return 0 to indicate that there is no such divisor.

    what I have so far:

    public static void main(String[] args {
    int[][] a = {{10,9,8,7,6,5,4,3,2,1}};
    System.out.println(Arrays.toString(a[0]));

    }
    }

  2. #2
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: Trying to make a largest divisor solver.

    You need to think this through mathematically as to how you would do it (for example with pencil and paper). Then convert that to Java code.

    Regards,
    Jim

Similar Threads

  1. Recursion, arrays and greatest common divisor
    By GalBenH in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 15th, 2012, 12:46 AM
  2. Automatic Solver
    By ppme in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 5th, 2011, 04:15 PM
  3. THE THREAD SOLVER
    By javapenguin in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 16th, 2010, 09:49 PM
  4. Sudoku solver
    By Elliott50 in forum Algorithms & Recursion
    Replies: 2
    Last Post: December 22nd, 2009, 02:03 PM
  5. Sudoku Solver
    By MysticDeath in forum Java Theory & Questions
    Replies: 5
    Last Post: September 19th, 2009, 09:33 PM