Sunday, June 14, 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

How to load CSS file based on condition using ReactJS hook?

October 8, 2020 beroza

How to pass data from child component to parent in ReactJS?

August 15, 2021 beroza

Replace All ?’s to Avoid Consecutive Repeating Characters

January 11, 2023 beroza

How to create a dialog or popup using CSS?

June 9, 2022 beroza

Largest 3-Same-Digit Number in String

December 30, 2022 beroza

How to create object without prototype in JavaScript?

December 25, 2022 beroza

Write a program to check if number has equal digit count and digit value

June 19, 2022 beroza

WordPress 404 page not found all pages except homepage

May 17, 2019 beroza

How to initialize List of String or List in Java?

July 18, 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.