Saturday, May 31, 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 

Return the next higher prime number

Published: February 11, 2022

Write a function that takes a number (a) as argument. If a is prime number, return a. If a is not prime number then return the next higher prime number.

const nextPrimeNumber = (num) => {
    for(let i = 2; i < num ; i++) {
        if(num % i === 0) {
            return nextPrimeNumber(num + 1)
        }

    }
    return num;
};

const input = 90;
console.log(nextPrimeNumber(input)); // 97

You May Also Like

How to use WordPress REST API from python?

August 30, 2019 beroza

Unable to load script from assets index.android.bundle

December 11, 2018 beroza

Difference Between Element Sum and Digit Sum of an Array

January 21, 2023 beroza

How to load JavaScript file dynamically?

July 26, 2021 beroza

What are the differences between application server and a servlet container?

November 25, 2019 beroza

MongoDB useful cheat sheet

November 14, 2021 beroza

TypeError: Cannot read property ‘setState’ of undefined ReactJS

March 3, 2020 beroza

Query in-stock products WooCommerce WordPress.

January 4, 2020 beroza

What is machine learning? What are different types of machine leanring methods?

July 12, 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

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.