Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:35:19+00:00 2026-06-13T16:35:19+00:00

Say there are n numbers from which we select p numbers (p less than

  • 0

Say there are “n” numbers from which we select “p” numbers (p less than n) such that the selected “p” numbers are sorted. A selected number can be repeated. How can we calculate the number of combinations we can select? For example if we have a set of numbers say {1,2,3,4,5,6} (n=6) and we are to select 3 numbers from the set (p=3) which are sorted. So we can have {1,2,3}, {1,1,2}, {2,3,6}, {4,5,5}, {5,5,5} …….. Since all of these combinations are sorted they are valid. How can we find the number of such sorted combinations we can get?


What I mean from the word sorted, is that when we select p elements from a set of numbers of n elements, the selected p elements should be sorted.

Take this small example:

If the set is {1,2,3,4} (so n = 4) and we are to select 3 elements (p = 3), the number of ways we can select p elements (with replacement) will be 4*4*4=64. So the selections will have {1,1,1},{1,1,2},{1,1,3}{1,1,4},{1,2,1}.....{3,1,1}...{4,4,4}. But in these selections, not all are sorted. In this example, {1,2,1} and {3,1,1} are not sorted.

I want to get the number of sorted selections.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:35:20+00:00Added an answer on June 13, 2026 at 4:35 pm

    I fail to see how the sorting affects the result. For each possible combination with repetitions, there will be a corresponding sorted permutation.

    Hence the question boils down to number of combinations of n elements taken p at a time with replacement. That is the straight forward formula, (n-1+p)C(p) = factorial(n-1+p) / (factorial(p) * factorial(n-1) )

    enter image description here

    Here is an explanation of the formula, and another one from wolfram.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to take any number, from say, 1 to 40000 and
Say that I have some SELECT statement: SELECT id, name FROM people ORDER BY
Say I have two files where there is one number per line File 1
Say I have an array of number a <- c(1,2,3,6,7,8,9,10,20) if there a way
say there is an xml file, which not created by me, with a known
Say there is a dict variable that grows very large during runtime - up
In PostgreSQL, there is this very useful string_agg function, that allows query like: SELECT
I need to select all numbers N (integers) between @min and @max Is there
I have a php form that searches a SQL database. There are say eight
I have a large set of data from which the user has to select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.