What do you want to save?
Add Code snippet
New code examples
-
Java 2022-03-26 13:40:11
generate all prime number less than n java
/** Author: Jeffrey Huang As far as I know this is almost the fastest method in java for generating prime numbers less than n. A way to make it faster would be to implement Math.sqrt(i) instead of i/2. I don't know if you could implement sieve of eratost... Add solution -
Java 2022-03-11 11:35:19
Java program to print prime numbers from 2 to n
// Java program to print prime numbers from 2 to n import java.util.Scanner; public class PrimeNumberFrom2Ton { public static void main(String[] args) { int loop, max; System.out.print("Please enter highest (maximum) number: "... Add solution -
Other 2022-02-13 11:45:07
prime of sieve
//sieve of eratosthenes or prime of sieve #include<iostream> #include<math.h> using namespace std; void primeofsieve(long long int n) { long long int arr[n]={}; for(int i=2;i<=sqrt(n);i++) { for(long long int j=i*i;j<=n;j+=i) arr... Add solution -
C# 2022-01-23 08:05:24
is prime number c#
using System; namespace Demo { class MyApplication { public static void Main() { int n = 5, a = 0; for (int i = 1; i <= n; i++) { ... Add solution -
Other 2022-01-22 00:40:21
c program to print prime number from 2 to n
#include<stdio.h> int main() { int n,i,fact,j; printf("Enter the Number"); scanf("%d",&n); printf("Prime Numbers are: \n"); for(i=1; i<=n; i++) { fact=0; for(j=1; j<=n; ... Add solution -
Python 2021-11-20 20:14:18
python basic programs
# Program to check if a number is prime or not num = 407 # To take input from the user #num = int(input("Enter a number: ")) # prime numbers are greater than 1 if num > 1: # check for factors for i in range(2,num): if (num % i... Add solution -
Other 2021-11-20 07:29:10
program to find sum of first n prime numbers in c
#include <stdio.h> int isprime(int j) { int count=0; for(int i = 2 ; i <= j/2; i++) { if(j%i == 0) { count = 1; } } if... Add solution -
CSS 2021-11-20 03:20:25
sieve of eratosthenes
// C++ program to print all primes smaller than or equal to // n using Sieve of Eratosthenes #include <bits/stdc++.h> using namespace std; void SieveOfEratosthenes(int n) { // Create a boolean array "prime[0..n]" and initialize /... Add solution