Friday, May 9, 2025
Latest:
  • Der kleine Vogel und die Sonne
  • German alphabet pronunciation
  • Command design pattern
  • German words with gender
  • When to use einen and keinen in German?
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

Write a program to determine color of a chessboard square

June 8, 2022 beroza

Detect a DOM element is visible in the current viewport?

September 16, 2019 beroza

kubectl useful commands that developers should know.

April 14, 2020 beroza

What is rest parameter? explain with example

May 12, 2019 beroza

How to load ad using Google Publisher Tag?

June 30, 2021 beroza

JavaScript topics to cover before interview

January 1, 2019 beroza

Write a JavaScript curry function to add n numbers

April 23, 2022 beroza

What are the correct file permission for WordPress site?

January 9, 2020 beroza

Can’t access mysql from command line Mac OS

August 27, 2019 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.