Sunday, October 12, 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

Write a Program to Find N-ary Tree Level Order Traversal

January 8, 2023 beroza

How to Install ngrok using brew on mac?

September 16, 2019 beroza

Write a Program to Find Maximum Ice Cream Bars

January 17, 2023 beroza

Write a program to merge strings alternately

June 14, 2022 Rinku Paul

Write a program to find the robot return to origin

June 17, 2022 beroza

Write a Program to Find Minimum Common Value

March 4, 2023 beroza

Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA

June 11, 2019 beroza

How to remove a property from a JavaScript object?

September 17, 2019 beroza

How to enable apache2 mod_rewrite on Mac?

September 2, 2019 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.