Friday, June 20, 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

Inheritance in JavaScript

August 29, 2021 beroza

What is Type Assertions in TypeScript?

November 11, 2021 beroza

How to remove a property from a JavaScript object?

September 17, 2019 beroza

What are different methods of JavaScript promises?

April 6, 2021 beroza

What is composition in object oriented programming?

December 16, 2023 beroza

Write a program to match decrement increment string

June 10, 2022 beroza

Reactjs app should use a boilerplate or use create-react-app from Facebook?

January 2, 2019 beroza

What is interface in Java? What are the differences between interface and class?

February 21, 2020 beroza

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

January 8, 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

Languages

  • EnglishEnglish
  • বাংলাবাংলা

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.