Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Mathur <[email protected]>
  • Loading branch information
Harsh-Mathur-1503 authored Nov 16, 2024
1 parent d212d48 commit d28ccce
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,13 @@
'use strict';

var linspace = require( '@stdlib/array/base/linspace' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var lcmf = require( './../lib' );

var nValues = linspace( 1.0, 20.0, 20 );
var numsA = linspace( 1.0, 10.0, 10 );
var numsB = discreteUniform( 100, 0, 10 );

// Iterate through the values and compute the LCM of two numbers
var i;
for ( i = 0; i < nValues.length - 1; i++ ) {
var a = nValues[i];
var b = nValues[i + 1];

// Ensure a and b are single-precision floating-point numbers (float32)
if ( typeof a === 'number' && typeof b === 'number' ) {
console.log( 'LCM of %d and %d = %d', a, b, lcmf( a, b ) );
} else {
console.log( 'Invalid input types. Both a and b should be single-precision floating-point numbers.' );
}
for ( i = 0; i < numsA.length; i++ ) {
console.log( 'lcmf(%d, %d) = %d', numsA[ i ], numsB[ i ], lcmf( numsA[ i ], numsB[ i ] ) );
}

0 comments on commit d28ccce

Please sign in to comment.