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

Differences between Preload, Prefetch, and Preconnect?

September 16, 2021 beroza

SEO checklist for your website

January 1, 2019 beroza

What is Cross-Site Request Forgery (CSRF)? Why CSRF is important?

September 4, 2022 beroza

What are the differences between Map vs Object in JavaScript?

August 30, 2021 beroza

Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA

June 11, 2019 beroza

How to convert timestamp to date object in JavaScript?

April 15, 2021 beroza

Useful intelliJ shortcuts those are good know.

March 22, 2020 beroza

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

June 19, 2022 beroza

How to copy WordPress live database to local database?

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