Diferencia entre revisiones de «Implementación de algoritmos de teoría de números/Criba de Eratóstenes»
Contenido eliminado Contenido añadido
Línea 136:
// Iker Ruiz Arnauda - 2012
// Sieve of Eratosthenes - C#
// Criba de Eratóstenes - C#
// This program will calculate prime numbers based on Eratosthenes algorithm,
// the result will be dumped into a txt file considering you use this to extract primes from a wide range.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
namespace Main
Línea 147 ⟶ 152:
static void Main(String[] Args)
{
Int32 primeFoundCounter = 0;
Boolean ended = false;
do
Línea 155 ⟶ 161:
//Read size of the array from the user, convert it to an Intiger.
var SuperiorLimit = Convert.ToInt32(Console.ReadLine());
//Create the array.
Boolean[] primesArray = new Boolean[SuperiorLimit];
Línea 174 ⟶ 180:
}
//
▲ Console.ForegroundColor = ConsoleColor.Green;
for (int j = 2; j < primesArray.Length; j++)▼
{
{
sw.WriteLine("[" + j + "] ");
primeFoundCounter++;
}
}
sw.Close();
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Found " + primeFoundCounter + " prime numbers");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Results were saved into: " + OutputPath + "\\Primes.txt.");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Press any key to exit...");
//Operation completed succesfully, we kill the loop.*/
|