承接 macfja/math 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

macfja/math

Composer 安装命令:

composer require macfja/math

包简介

A set of tools around Mathematics.

README 文档

README

A set of class and function around Mathematics.

What inside ?

CombinationBuilder

An utility class to create combination. The class also provide a factorial calculation.

Example and Usage

Combination

Get for 3 in 5:

print_r(CombinationBuilder::getCombination(5, 3));

Will output:

Array
(
    [1-2-3] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

    [1-2-4] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 4
        )

    [1-2-5] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 5
        )

    [1-3-4] => Array
        (
            [0] => 1
            [1] => 3
            [2] => 4
        )

    [1-3-5] => Array
        (
            [0] => 1
            [1] => 3
            [2] => 5
        )

    [1-4-5] => Array
        (
            [0] => 1
            [1] => 4
            [2] => 5
        )

    [2-3-4] => Array
        (
            [0] => 2
            [1] => 3
            [2] => 4
        )

    [2-3-5] => Array
        (
            [0] => 2
            [1] => 3
            [2] => 5
        )

    [2-4-5] => Array
        (
            [0] => 2
            [1] => 4
            [2] => 5
        )

    [3-4-5] => Array
        (
            [0] => 3
            [1] => 4
            [2] => 5
        )

)

Or in a more compact way:

(1, 2, 3)
(1, 2, 4)
(1, 2, 5)
(1, 3, 4)
(1, 3, 5)
(1, 4, 5)
(2, 3, 4)
(2, 3, 5)
(2, 4, 5)
(3, 4, 5)

Combination Count

Get the number of possible combination

print_r(CombinationBuilder::getCombinationCount(5, 3));

Will output:

10

Factorial

Get the factorial of 5 (5!)

print_r(CombinationBuilder::factorial(5));

Will output:

120

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固