Saturday, November 15, 2025
Latest:
  • 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?
  • German Pronouns with Nominative, Accusative, and Dative cases
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Write an efficient program to print prime numbers.

Published: November 19, 2021 code, JavaScript, number, prime, prime number

What is a prime number?

Prime numbers are numbers that are greater than 1 and it has only two factors, 1 and the number itself.

The solution to print prime number:

Following is the code to write prime number up to 20 in JavaScript.

    for(let i = 2; i < 20; i++){
        for(let j = 2; j <= i; j++) {
            if(i % j === 0 && j !== i){
                break;
            }

            if (i === j) {
                console.log(i);
            }
        }
    }

You May Also Like

How to add attribute or property to an array of objects in JavaScript?

April 6, 2021 beroza

Find the Longest Balanced Substring of a Binary String

May 12, 2023 beroza

could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket

October 11, 2020 beroza

How to check multiple PHP versions available on Ubuntu?

July 15, 2021 beroza

Refresh meta tag not working properly

January 1, 2019 beroza

Longest Nice Substring

December 31, 2022 beroza

Convert an Array Into a 2D Array With Conditions

May 28, 2023 beroza

What is SaaS, PaaS and IaaS? Explain with example

May 9, 2019 beroza
Wi-Fi

What is Wi-Fi? What are the advantages and disadvantages of Wi-Fi?

June 15, 2022 Griza Paul

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.