Horje
prime number generator Code Example
prime number generator
using System;
public class Program
{
    static void Main(string[] args)
    {
        var results = GenerateSieve(1000);
        var i=0;
        foreach (var item in results)
        {
            if(item) Console.Write(i + " ");
            i++;
        }
    }
 
    static bool[] GenerateSieve(int num)
    {
        // Creating an array indicating whether numbers are prime.
        bool[] isPrime = new bool[num + 1];
        for (int i = 2; i <= num; i++) isPrime[i] = true;
 
        // Removing out multiples.
        for (int i = 2; i <= num; i++)
        {
            // Check if i is prime.
            if (isPrime[i])
            {
                // Eliminate multiples of i.
                for (int j = i * 2; j <= num; j += i)
                    isPrime[j] = false;
            }
        }
        return isPrime;
    }
}
Source: ideone.com




Csharp

Related
you have the following c# code. sb is a a very long string. you need to identify whether a string stored in an object named stringtofind is within the stringbuilder sb object. which code shou you have the following c# code. sb is a a very long string. you need to identify whether a string stored in an object named stringtofind is within the stringbuilder sb object. which code shou
visual studio debug copy byte[] from watch Code Example visual studio debug copy byte[] from watch Code Example
c# reopen form if open Code Example c# reopen form if open Code Example
selenum wait for element c# Code Example selenum wait for element c# Code Example
c# C# read text from a certain line number from string Code Example c# C# read text from a certain line number from string Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11