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 4 of 4

Thread: how to find number of different combination of 100

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Location
    Bangalore
    Posts
    20
    My Mood
    Fine
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default how to find number of different combination of 100

    How many different ways can one hundred be written as a sum of at least two positive integers?

    I am not getting algo. please any one can give me write solution of this problem


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,618
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: how to find number of different combination of 100

    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: how to find number of different combination of 100

    Quote Originally Posted by freakycoder View Post
    ...I am not getting algo. please any one can give me write solution of this problem
    That's not how this forum works.

  4. #4
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: how to find number of different combination of 100

    Quote Originally Posted by freakycoder View Post
    How many different ways can one hundred be written as a sum of at least two positive integers?

    I am not getting algo
    Does "algo" mean algorithm?

    Well...

    This is related to a well-known topic in number theory: Integer Partitions

    Here is an illustration of how calculation of a partition number (size of the set of partitions of a positive integer) relates to your assignment:

    Let's look at the number of ways of writing a particular number, 5, as the sum of positive integers:

    Note that p(5) = 7 and the seven ways of writing 5 as the sum of positive integers are:

    5
    4 + 1
    3 + 2
    3 + 1 + 1
    2 + 2 + 1
    2 + 1 + 1 + 1
    1 + 1 + 1 + 1 + 1


    Note also that, except for the first one, each of these lines (called parts or partitions of the number) consists of the sum of two or more positive integers.

    Making a slight inductive leap (without formal proof):

    The algorithm for finding the number of ways of writing 100 as the sum of two or more positive integers is:

    1. Calculate p(100).

    2. The answer is p(100)-1.



    Finally, note that using partition number calculations as outlined in the Wikipedia article (and myriads of other references) depends on the following convention:

    Two sums that differ only in the order of their terms are considered to be the same partition.
    That is, 2+3 is the same as 3+2, so you don't count that as two different partitions.
    Similarly, 2+2+1 is the same as 2+1+2, and is the same as 1+2+2.
    Etc.


    Cheers!

    Z

Similar Threads

  1. generate a random number from 100 to 150, inclusive in applet
    By chonch in forum Java Theory & Questions
    Replies: 12
    Last Post: February 14th, 2014, 04:44 AM
  2. Use a boolean to find if a number is divisible
    By ColeTrain in forum Java Theory & Questions
    Replies: 5
    Last Post: October 3rd, 2012, 05:16 PM
  3. Find prime nums from 1-100 algorithm
    By The-EyE in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 5th, 2012, 10:39 PM
  4. Find the two largest number
    By vendettabf in forum What's Wrong With My Code?
    Replies: 15
    Last Post: December 29th, 2011, 12:23 PM
  5. Replies: 4
    Last Post: June 10th, 2009, 01:04 AM