- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Greatest number divisible by n within a bound in JavaScript
Problem
We are required to write a JavaScript function that takes in a number n and bound number b.
Our function should find the largest integer num, such that −
num is divisible by divisor
num is less than or equal to bound
num is greater than 0.
Example
Following is the code −
const n = 14; const b = 400; const biggestDivisible = (n, b) => { let max = 0; for(let j = n; j <= b; j++){ if(j % n == 0 && j > max){ max = j; }; } return max; }; console.log(biggestDivisible(n, b));
Output
392
- Related Articles
- Generating a random number that is divisible by n in JavaScript
- Finding the count of numbers divisible by a number within a range using JavaScript
- Smallest number that is divisible by first n numbers in JavaScript
- Greatest Sum Divisible by Three in C++
- Sum which is divisible by n in JavaScript
- Smallest possible number divisible by all numbers from 1 to n in JavaScript
- Determine the greatest four-digit number which is exactly divisible by 10,12,16.?
- Determine the greatest 3 digit number exactly divisible by 8, 10, and 12.
- Count n digit numbers divisible by given number in C++
- Find the greatest 3 digit number which is divisible by the number 4 ,5 and 6.
- Greatest digit of a number in JavaScript
- Find the greatest 5 digit number that is exactly divisible by 22,25 and 30
- Find N digits number which is divisible by D in C++
- Largest N digit number divisible by given three numbers in C++
- Finding a pair that is divisible by some number in JavaScript

Advertisements