1 den 1000'e Kadar Olan Asal Sayılar

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ConsoleApplication21
{
    class Program
    {
        static void Main(string[] args)
        {
            int y = 0;
            ArrayList asal = new ArrayList();
            for (int j = 1; j <= 1000; j++)
            {
                y = j - 2;
                for (int i = 2; i < j; i++)
                {

                    if (j % i != 0)
                    {

                        y--;
                    }
                    if (y == 0)
                    {
                        asal.Add(j);
                    }
                }
            }
            asal.Add(2);
            asal.Sort();
            foreach (var x in asal)
            {
                Console.WriteLine(x);
            }
        }
    }
}

Yorum Gönder

0 Yorumlar