Wednesday, December 10, 2025
Latest:
  • 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?
  • How Spring framework resolves circular dependencies?
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 Find Maximum Population Year

May 11, 2023 beroza

TypeError: Cannot assign to read only property of object ‘#Object’ reactjs

April 15, 2019 beroza

How to clone an EC2 instance in AWS?

November 13, 2019 beroza

Why next-gen image formats (JPEG2000, WebP) are better compare to JPEG, PNG formats?

January 8, 2021 beroza

Write a Program to Find Min Max Game

May 17, 2023 beroza

How to redirect to another route onclick ReactJS?

October 23, 2019 beroza

Is there a print_r or var_dump equivalent in Ruby on Rails?

May 27, 2020 beroza

What are Different Types of Parentheses?

June 8, 2023 beroza

Write a JavaScript curry function to add n numbers

April 23, 2022 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.