Tuesday, August 4, 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

Write a Program to Find Two Furthest Houses With Different Colors

January 20, 2023 beroza

What is rest parameter? explain with example

May 12, 2019 beroza

Should we commit yarn.lock and package-lock.json files?

July 2, 2020 beroza

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

May 24, 2020 beroza

Write a Program to Find Remove Duplicates from Sorted Array

January 23, 2023 beroza

Write a Program to Find Minimum Moves to Convert String

January 12, 2023 beroza

How to make dynamic variable names in Java?

May 8, 2020 beroza

Calculate the sum of numbers from 1 to n using recursion

June 17, 2023 beroza

Consider static factory methods instead of constructors

January 23, 2020 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.