time-to-botec

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

README.md (2743B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2020 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 # isPrime
     22 
     23 > Test if a value is a prime number.
     24 
     25 <section class="intro">
     26 
     27 A **prime number** is defined as an integer value greater than `1` which is only divisible by `1` and itself.
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <section class="usage">
     34 
     35 ## Usage
     36 
     37 ```javascript
     38 var isPrime = require( '@stdlib/assert/is-prime' );
     39 ```
     40 
     41 #### isPrime( value )
     42 
     43 Tests if a `value` is a prime number.
     44 
     45 <!-- eslint-disable no-new-wrappers -->
     46 
     47 ```javascript
     48 var Number = require( '@stdlib/number/ctor' );
     49 
     50 var bool = isPrime( 5.0 );
     51 // returns true
     52 
     53 bool = isPrime( new Number( 5.0 ) );
     54 // returns true
     55 
     56 bool = isPrime( 3.14 );
     57 // returns false
     58 
     59 bool = isPrime( -5.0 );
     60 // returns false
     61 
     62 bool = isPrime( NaN );
     63 // returns false
     64 
     65 bool = isPrime( null );
     66 // returns false
     67 ```
     68 
     69 #### isPrime.isPrimitive( value )
     70 
     71 Tests if a `value` is a primitive prime number.
     72 
     73 <!-- eslint-disable no-new-wrappers -->
     74 
     75 ```javascript
     76 var Number = require( '@stdlib/number/ctor' );
     77 
     78 var bool = isPrime.isPrimitive( 5.0 );
     79 // returns true
     80 
     81 bool = isPrime.isPrimitive( new Number( 5.0 ) );
     82 // returns false
     83 ```
     84 
     85 #### isPrime.isObject( value )
     86 
     87 Tests if a `value` is a `Number` object having a value which is a prime number.
     88 
     89 <!-- eslint-disable no-new-wrappers -->
     90 
     91 ```javascript
     92 var Number = require( '@stdlib/number/ctor' );
     93 
     94 var bool = isPrime.isObject( 5.0 );
     95 // returns false
     96 
     97 bool = isPrime.isObject( new Number( 5.0 ) );
     98 // returns true
     99 ```
    100 
    101 </section>
    102 
    103 <!-- /.usage -->
    104 
    105 <section class="examples">
    106 
    107 ## Examples
    108 
    109 <!-- eslint-disable no-new-wrappers -->
    110 
    111 <!-- eslint no-undef: "error" -->
    112 
    113 ```javascript
    114 var Number = require( '@stdlib/number/ctor' );
    115 var isPrime = require( '@stdlib/assert/is-prime' );
    116 
    117 var bool = isPrime( 5.0 );
    118 // returns true
    119 
    120 bool = isPrime( new Number( 5.0 ) );
    121 // returns true
    122 
    123 bool = isPrime( 11.0 );
    124 // returns true
    125 
    126 bool = isPrime( 2.0 );
    127 // returns true
    128 
    129 bool = isPrime( 3.14 );
    130 // returns false
    131 
    132 bool = isPrime( -5.0 );
    133 // returns false
    134 
    135 bool = isPrime( NaN );
    136 // returns false
    137 
    138 bool = isPrime( '0.5' );
    139 // returns false
    140 
    141 bool = isPrime( null );
    142 // returns false
    143 ```
    144 
    145 </section>
    146 
    147 <!-- /.examples -->
    148 
    149 <section class="links">
    150 
    151 </section>
    152 
    153 <!-- /.links -->