time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (3136B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # lcm
     22 
     23 > Compute the [least common multiple][lcm] (lcm).
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 The [least common multiple][lcm] (lcm) of two non-zero integers `a` and `b` is the smallest positive integer that is divisible by both `a` and `b`. The lcm is also known as the **lowest common multiple** or **smallest common multiple** and finds common use in calculating the **lowest common denominator** (lcd).
     30 
     31 </section>
     32 
     33 <!-- /.intro -->
     34 
     35 <!-- Package usage documentation. -->
     36 
     37 <section class="usage">
     38 
     39 ## Usage
     40 
     41 ```javascript
     42 var lcm = require( '@stdlib/math/base/special/lcm' );
     43 ```
     44 
     45 #### lcm( a, b )
     46 
     47 Computes the [least common multiple][lcm] (lcm).
     48 
     49 ```javascript
     50 var v = lcm( 48, 18 );
     51 // returns 144
     52 ```
     53 
     54 If either `a` or `b` is `0`, the function returns `0`.
     55 
     56 ```javascript
     57 var v = lcm( 0, 0 );
     58 // returns 0
     59 
     60 v = lcm( 2, 0 );
     61 // returns 0
     62 
     63 v = lcm( 0, 3 );
     64 // returns 0
     65 ```
     66 
     67 Both `a` and `b` must have integer values; otherwise, the function returns `NaN`.
     68 
     69 ```javascript
     70 var v = lcm( 3.14, 18 );
     71 // returns NaN
     72 
     73 v = lcm( 48, 3.14 );
     74 // returns NaN
     75 
     76 v = lcm( NaN, 18 );
     77 // returns NaN
     78 
     79 v = lcm( 48, NaN );
     80 // returns NaN
     81 ```
     82 
     83 </section>
     84 
     85 <!-- /.usage -->
     86 
     87 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     88 
     89 <section class="notes">
     90 
     91 </section>
     92 
     93 <!-- /.notes -->
     94 
     95 <!-- Package usage examples. -->
     96 
     97 <section class="examples">
     98 
     99 ## Examples
    100 
    101 <!-- eslint no-undef: "error" -->
    102 
    103 ```javascript
    104 var randu = require( '@stdlib/random/base/randu' );
    105 var round = require( '@stdlib/math/base/special/round' );
    106 var lcm = require( '@stdlib/math/base/special/lcm' );
    107 
    108 var a;
    109 var b;
    110 var v;
    111 var i;
    112 
    113 for ( i = 0; i < 100; i++ ) {
    114     a = round( randu()*50 );
    115     b = round( randu()*50 );
    116     v = lcm( a, b );
    117     console.log( 'lcm(%d,%d) = %d', a, b, v );
    118 }
    119 ```
    120 
    121 </section>
    122 
    123 <!-- /.examples -->
    124 
    125 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    126 
    127 <section class="references">
    128 
    129 </section>
    130 
    131 <!-- /.references -->
    132 
    133 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    134 
    135 <section class="links">
    136 
    137 [lcm]: https://en.wikipedia.org/wiki/Least_common_multiple
    138 
    139 </section>
    140 
    141 <!-- /.links -->