Wednesday, July 15, 2026
Latest:
  • Präsentation für b1
  • Verb “werden” Konjugation
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
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

How to render and return html using render_to_string in rails?

May 27, 2020 beroza

What are the rules of determining value of keyword “this” in JavaScript?

March 12, 2019 beroza

How to switch PHP versions for apache2 and command line?

May 15, 2019 beroza

Consider implementing comparable of a class in Java

February 6, 2020 beroza

301 Redirect vs Canonical – which one to use?

September 23, 2020 beroza

apache2.service failed “systemctl status apache2.service” and “journalctl -xe” for details

November 13, 2019 beroza

How to enable apache2 mod_rewrite on Mac?

September 2, 2019 beroza

Longest Nice Substring

December 31, 2022 beroza

Useful command that developers should know

July 31, 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 © 2026 Upokary. All rights reserved.