3 Replies Latest reply: Aug 11, 2008 2:36 AM by 791266 RSS

    random number possiblies

    807589
      Random number possibilites
      Eg: input we given

      2
      3
      4

      The Output will be
      234
      243
      324
      342
      423
      432
      this is output.
      The possiblities will come how many input numbers u r enter that
      Ex: u entered 3 digits that factorial is 6
      u entered 4 digits that factorial is 24 possiblilites will come
      This is the Problem i am faceing
        • 1. Re: random number possiblies
          807589
          Permutation and Combination is the way to go if you don't want to brute force it.

          [http://tutors4you.com/permutationcombinationtutorial.htm]

          Well, if you want to brute force it (you will have to brute force it for the output you want), an ugly loop will do.

          As for factorials, you can probably use any loop. Personally, I like to make a recursive method. Something like this:
          public static long factorial(int num) {
                 return num == 0 ? 1 : num * factorial(num - 1);
          }
          Here is also a very very important article to read:

          [http://www.catb.org/~esr/faqs/smart-questions.html]

          I cannot stress how much you need to read it. Just read it and read every single word of it. You will be enlightened, I promise. :)

          Have fun.
          • 2. Re: random number possiblies
            807589
            Multiposted all over the place!
            • 3. Re: random number possiblies
              791266
              @Op. I have removed your cross-posts, so this is the only thread that is left. Please don't cross-post in the future.

              Kaj