TODO: Permutation combination problem: N number of M

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

TODO: Permutation combination problem: N number of M


Permutation and combination is the most basic concept of combinatorial learning. The so-called arrangement refers to the ordering of the specified number of elements from the given number of elements. The combination refers to the only number of elements from the given number of elements, regardless of the order. The central problem with permutation combinations is to study the total number of possible scenarios for the permutations and combinations of a given requirement. The permutation combination is closely related to the classical probability theory.

The function of this article is to "sequentially" take the number of m from the n number, such as 1,2,3,4,5,6 take 5 numbers is: 1,2,3,4,5;1,2,3,4,6;2,3,4,5,6. Sample code has Javascript,php,golang, if similar, purely academic research, as a record, thank you for your support. The code is tested and can be used normally. The algorithm that uses factorial.

JS: Get n number of M number, how many groups of combinations


PHP: Get an array of n numbers from an array


Golang: Permutation combination problem: N number of M





Algorithm is the essence of software.

Wxgzh:ludong86


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.