Sunday, October 5, 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

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

November 25, 2019 beroza

What are the real world use case of proxy design pattern?

October 10, 2024 beroza

Write a Program to Find Maximum Binary Tree

January 15, 2023 beroza

What are the differences between forward proxy server and reverse proxy server?

January 15, 2019 beroza

How to redirect to another route onclick ReactJS?

October 23, 2019 beroza

What are the differences between NoSQL vs SQL Databases?

December 5, 2021 beroza

WordPress must have plugins for business websites

August 30, 2019 beroza

Useful yarn commands for developers

July 27, 2021 beroza

How to sort an array of objects in JavaScript?

April 10, 2021 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 © 2025 Upokary. All rights reserved.