Find quotient and remainder by dividing an integer in JavaScript Last Updated : 02 Jun, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will find the quotient and remainder by dividing an integer in JavaScript. There are various methods to divide an integer number by another number and get its quotient and remainder. Using Math.floor() methodUsing ~~ operatorright shift >> operator Example 1: This example uses the Math.floor() function to calculate the divisor. JavaScript let a = 39; let b = 5; function Geeks() { console.log("quotient = " + Math.floor(a / b)) console.log("remainder = " + a % b); } Geeks() Outputquotient = 7 remainder = 4 Example 2: This example uses the binary ~~ operator to calculate the divisor. JavaScript let a = 39; let b = 5; function Geeks() { let num = ~~(a / b); console.log("quotient = " + num) console.log("remainder = " + a % b); } Geeks() Outputquotient = 7 remainder = 4 Example 3:This example uses the right shift >> operator to calculate the divisor. JavaScript let a = 39; let b = 5; function Geeks() { let num = (a / b) >> 0; console.log("quotient = " + num) console.log("remainder = " + a % b); } Geeks() Outputquotient = 7 remainder = 4 Comment More infoAdvertise with us Next Article Find quotient and remainder by dividing an integer in JavaScript P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies javascript-math JavaScript-Questions Similar Reads JavaScript Program to Print Multiplication Table of a Number We are given a number n as input, we need to print its table. Below are the different approaches to print multiplication table in JavaScriptJavaScript Program to print multiplication table of a number1. Using a for LoopThis is the most common way to print the multiplication table. A for loop repeats 3 min read What is the use of Math object in JavaScript ? The Math object in JavaScript provides a set of methods and properties for mathematical constants and functions. It is a built-in object that allows for performing mathematical operations and accessing mathematical constants without creating an instance.What is the Math Object?The Math object is an 4 min read How to get median of an array of numbers in JavaScript ? In this article, we will see how to find the median of an array using JavaScript. A median is a middle value in a given set of numbers or data. Examples: Input arr1 : [1 4 7 9]Output : 5.5Explanation : The median of the two sorted array is the middle elements which is 5 if the arrayLength =arr1.leng 3 min read How to calculate greatest common divisor of two or more numbers/arrays in JavaScript ? In this article, we are given two or more numbers/array of numbers and the task is to find the GCD of the given numbers/array elements in JavaScript. Examples: Input : arr[] = {1, 2, 3} Output : 1 Input : arr[] = {2, 4, 6, 8} Output : 2 The GCD of three or more numbers equals the product of the prim 2 min read How to test a value x against predicate function and returns fn(x) or x in JavaScript ? In this article, we are given a value x, and the task is to check the value against the predicate function. If the value satisfies the condition or predicate return fn(x) else return x. Predicate functions are the function that takes one item as input and returns true or false based on the whether i 3 min read How to Flatten a Given Array up to Specified Depth in JavaScript? Flatten an array in JavaScript is a common task when dealing with nested arrays. The concept of "flatten" means to convert a multi-dimensional array into a single-dimensional array. When you need to control the depth of flattening, JavaScript provides methods to handle this efficiently. This process 2 min read How to get the standard deviation of an array of numbers using JavaScript ? Given an array and the task is to calculate the standard deviation using JavaScript. Example: Input: [1, 2, 3, 4, 5]Output: 1.4142135623730951Input: [23, 4, 6, 457, 65, 7, 45, 8]Output: 145.13565852332775Please refer to Mean, Variance, and Standard Deviation for details. Mean is average of element. 3 min read How to evaluate binomial coefficient of two integers n and k in JavaScript ? The following are the common definitions of Binomial Coefficients. A binomial coefficient C(n, k) can be defined as the coefficient of x^k in the expansion of (1 + x)^n. Binomial coefficient C(n, k) also gives the number of ways, disregarding order, that k objects can be chosen from among n objects 2 min read How to check two numbers are approximately equal in JavaScript ? In this article, we are given two numbers and the task is to check whether the given numbers are approximately equal to each other or not. If both numbers are approximately the same then print true otherwise print false. Example: Input: num1 = 10.3 num2 = 10 Output: true Approach: To check whether t 2 min read How to create slider to map a range of values in JavaScript ? The task is to map a range of values to another range of values like map (0-100) to (100-10000000) in JavaScript. There are two approaches that are discussed below.Approach 1: Use the logarithmic scale to map the range. In this example, first, the log value of the range is calculated and then the sc 2 min read Like