Thursday, May 26, 2022
Latest:
  • How to specify type in object destructuring?
  • How to compile TypeScript in command line?
  • How to lower blood triglycerides?
  • Factory method design pattern JavaScript
  • Write a JavaScript curry function to add n numbers
Upokary

Upokary

Quality information

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

Write an efficient program to print prime numbers.

Published: November 19, 2021code, 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

What are the differences between .bash_profile vs .bashrc?

July 31, 2019 beroza

Uncaught TypeError: CreateListFromArrayLike called on non-object

April 1, 2019 beroza

Execution failed for task ‘:app:installDebug’ react native run android

December 5, 2018 beroza

How to specify type in object destructuring?

April 28, 2022 beroza

Uncaught TypeError: iterable is not iterable

May 21, 2019 beroza

What is Arc publishing? Explain the Arc publishing architecture

July 18, 2019 beroza

REST API best practices

February 23, 2022 beroza

JavaScript “let” and “var” related interview questions

March 19, 2019 beroza

How to get URL query parameter value from query string in ReactJS?

February 24, 2020 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 © 2022 Upokary. All rights reserved.