Skip to content

digital-technology-agency/math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mathematical and algorithms experiments

go

Intro

GoDoc Go Go Report Card License Website dta.agency GitHub release open collective badge

 Агентство цифровых технологий

Menu

Sorted

Mathematical

Examples

C from n to k

Card information

Let there be n different objects. To find the number of combinations of n objects by k, we will choose combinations of m objects in all possible ways, while paying attention to the different composition of the combinations, but not the order (it is not important here, unlike the placements).

Factorial

Card information

The factorial operation is encountered in many areas of mathematics, notably in combinatorics, algebra, and mathematical analysis. Its most basic use counts the possible distinct sequences – the permutations – of n distinct objects: there are n!.

Permutations (n)

Pn = n!

Permutations differ from combinations, which are selections of some members of a set regardless of order. For example, written as tuples, there are six permutations of the set {1,2,3}, namely: (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), and (3,2,1). These are all the possible orderings of this three-element set. Anagrams of words whose letters are different are also permutations: the letters are already ordered in the original word, and the anagram is a reordering of the letters. The study of permutations of finite sets is an important topic in the fields of combinatorics and group theory.

Placements (n)

Card information

If you are already familiar with combinations, then you will easily notice that in order to find placements, you need to take all possible combinations, and then change the order in each one in all possible ways (that is, in fact, make more permutations). Therefore, the number of placements is also expressed in terms of the number of permutations and combinations

Issues

GitHub issues GitHub closed issues

Usage

go get github.com/digital-technology-agency/math/pkg/combinatorics

Test

go test -run ''

Quickstart

C from n to k

import "github.com/digital-technology-agency/math/pkg/combinatorics"

func Example() {
    n := 100
    k := 3
    value := combinatorics.CnkUint(n, k)
	fmt.Printf("Result: %d", value)
    /*
        Result: 161700    
    */ 
}

Performance

If you don't need an ordered list of, Process's would be the best choice for large n.

N n k Process
1 100 3 0.00s
2 100000 3 0.09s
3 1000000 3 3.52s

Factorial (n!)

import "github.com/digital-technology-agency/math/pkg/combinatorics"

func Example() {
    n := 4
    value := combinatorics.FactorialInt(n)
	fmt.Printf("Result: %d", value)
    /*
        Result: 24    
    */ 
}

If you don't need an ordered list of factorial, Process's would be the best choice for large n.

N n! Process
1 10 0.00s
2 100000 0.16s
3 1000000 1.76s

Permutations (n)

import "github.com/digital-technology-agency/math/pkg/combinatorics"

func Example() {
    n := 4
    value := combinatorics.PermutationsInt(n)
	fmt.Printf("Result: %d", value)
    /*
        Result: 24    
    */ 
}

Placements (A from n to k)

import "github.com/digital-technology-agency/math/pkg/combinatorics"

func Example() {
    n := 10
    k := 10
    value := combinatorics.PlacementInt(n,k)
	fmt.Printf("Result: %d", value)
    /*
        Result: 3628800    
    */ 
}

Run in Terminal

  • Go to main page and click Releases

Card information

  • Choose a version for your operating system and click the link

Card information

  • Download and unzip the math file

Card information Card information

  • Open terminal in unzip folder

Card information

  • Run unzip binary file math and show list types
 ./math

Card information

  • Comand argument list
 ./math -h

Card information

  • Set arguments
 ./math -n=10000 -k=10

Contributing

Pull requests and Github issues are welcome. Please read our contributing guide for more information.

Агентство цифровых технологий