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 

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

error reading tomcat-embed-core.jar; zip file is empty

January 30, 2019 beroza

How to map all quotation marks to double quote?

June 8, 2022 beroza

How to uninstall android studio from Ubuntu 16.04 or 18.04?

December 4, 2018 beroza

MySQL ERROR 1045 (28000): Access denied for user ‘mentor’@’localhost’

February 3, 2020 beroza

Construct the Smallest Number From DI String

January 10, 2023 beroza

Compare Strings by Frequency of the Smallest Character

January 4, 2023 beroza

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

July 12, 2020 beroza

Write a Program to Make The String Great

December 31, 2022 beroza

What are the reasons of Kafka rebalancing?

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