Code Monkey home page Code Monkey logo

arithmetic-calc's Introduction

Calculator

Powerful Modern Math Library for PHP

Calculator is the only library you need to integrate mathematical functions into your applications. It is a self-contained library in pure PHP with no external dependencies.

It is actively under development with development (0.y.z) releases.

License

Prerequisites

Usage

<?php
use Calc\Arithmetic\ArithmeticFunctions;

echo ArithmeticFunctions::lcm(3, 4); //12
echo "<br/>";
echo ArithmeticFunctions::lcmm([3, 4, 60]); //60
echo "<br/>";
echo ArithmeticFunctions::gcd(8, 12); // 4
echo "<br/>";
echo ArithmeticFunctions::gcd(8, 0); // 8
echo "<br/>";
echo ArithmeticFunctions::gcdm(array(42, 56, 28)); // 14
echo "<br/>";
echo ArithmeticFunctions::average(array(42, 56)); // 49
echo "<br/>";
echo ArithmeticFunctions::average(array(42, 56, 28)); // 42
echo "<br/>";
print_r(ArithmeticFunctions::factors(42)); // ( [0] => 1 [1] => 2 [2] => 3 [3] => 6 [4] => 7 [5] => 14 [6] => 21 [7] => 42 )
echo "<br/>";
print_r(ArithmeticFunctions::factors(2)); //  ( [0] => 1 [1] => 2 )
echo "<br/>";
print_r(ArithmeticFunctions::factors(0)); //  ( [0] => 0 )
echo "<br/>";
print_r(ArithmeticFunctions::primeFactors(42)); // ( [0] => 2 [1] => 3 [2] => 7 )
echo "<br/>";
print_r(ArithmeticFunctions::primeFactors(39)); //  ( [0] => 3 [1] => 13 )
echo "<br/>";
print_r(ArithmeticFunctions::primeFactors(0)); //  (  )
echo "<br/>";
print(ArithmeticFunctions::weightedAverage(array(
    35 => 1000,
    15 => 2000,
    30 => 100,
    10 => 90,
    5 => 100,
    5 => 3120
))); //  889.47
echo "<br/>";
print(ArithmeticFunctions::weightedAvegare(array(
    2 => 42,
    3 => 56,
    9 => 28,
))); //  36

Getting the library

$ composer require calc/arithmetic

arithmetic-calc's People

Contributors

dobariyabhumika avatar bhumikadobariya avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.