Saturday, October 25, 2025
Latest:
  • German Pronouns with Nominative, Accusative, and Dative cases
  • German articles for the nominative, accusative, and dative cases
  • Der kleine Vogel und die Sonne
  • German alphabet pronunciation
  • Command design pattern
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Find next higher natural number that is divisble by another number

Published: February 11, 2022Last updated: February 11, 2022

Write a function that takes two numbers, say x and y, as arguments. We need to check if x is divisible by y. If yes, then return x. If not, return the next higher natural number that is divisible by y.

const findDivisble = (x, y) => {
   if (x % y === 0) return x;

   if(y < 0) return 0;

   const divisor = parseInt(x / y);
   return divisor * y + y;
}

console.log(findDivisble(7, 3)); // 9

You May Also Like

npm ERR! code ELIFECYCLE or Error: Could not locate the bindings file

September 6, 2018 beroza

req.body undefined in express.js

November 14, 2021 beroza

How to prevent a log file from being too big using logrotate?

June 9, 2021 beroza

What are the differences between NoSQL vs SQL Databases?

December 5, 2021 beroza

What is the Temporal Dead Zone in JavaScript?

August 30, 2021 beroza

How to specify type in object destructuring?

April 28, 2022 beroza

Difference between a node module and a package in Node.js?

January 4, 2022 beroza

What are the steps to run a ruby and rails project after cloning from Github?

May 21, 2020 beroza

Execution failed for task ‘:app:installDebug’ react native run android

December 5, 2018 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2025 Upokary. All rights reserved.