Skip to content

Instantly share code, notes, and snippets.

View mcmullm2-dcu's full-sized avatar

Michael McMullin mcmullm2-dcu

  • Dublin, Ireland
View GitHub Profile
@mcmullm2-dcu
mcmullm2-dcu / PrimesSieve.java
Last active February 4, 2018 10:01
Java implementation of the Sieve of Eratosthenes, an algorithm to calculate prime numbers.
/**
* Implementation of the sieve of Eratosthenes for finding all the primes up to
* a given number (MAX in this case).
* From the command line:
* Step 1 (compile): javac PrimesSieve.java
* Step 2 (run): java PrimesSieve
*/
public class PrimesSieve {
public static void main(String[] args) {
final int MAX = 1_000_000;
@mcmullm2-dcu
mcmullm2-dcu / PrimesSieve.cs
Created February 4, 2018 10:05
C# implementation of the Sieve of Eratosthenes, an algorithm to calculate prime numbers.
using System;
/// Implementation of the sieve of Eratosthenes for finding all the primes up to
/// a given number (MAX in this case).
/// From the command line:
/// Step 1 (Compile): csc PrimesSieve.cs
/// Step 2 (Run): .\PrimesSieve
public class PrimesSieve {
static void Main() {
const int MAX = 1000000;
@mcmullm2-dcu
mcmullm2-dcu / psieve.c
Created February 6, 2018 18:59
C implementation of the Sieve of Eratosthenes, an algorithm to calculate prime numbers.
/*
* Implementation of the sieve of Eratosthenes for finding all the primes up to
* a given number (MAX in this case).
* From the command line:
* Step 1 (compile): gcc psieve.c -o psieve
* Step 2 (run): ./psieve
*/
#include <stdio.h>
#include <math.h>