Saturday, April 25, 2026
Latest:
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
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

Error java.lang.OutOfMemoryError: GC overhead limit exceeded

May 11, 2019 beroza

How to get total days between two dates in JavaScript?

December 22, 2018 beroza

What are the differences between .bash_profile vs .bashrc?

July 31, 2019 beroza

What are the differences between Call, Apply and Bind in JavaScript?

August 30, 2021 beroza

Count the Number of Vowel Strings in Range

May 28, 2023 beroza

How to define error codes and error messages in Java?

July 20, 2020 beroza

What is TypeScript? Why should we use TypeScript?

October 28, 2021 beroza

What is CircleCI and why should we use it compare to other CI/CD?

January 13, 2021 beroza

Write a Program to Find Subarrays With Equal Sum

May 14, 2023 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.