using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace asal_sayılar
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
int sayac=0, adet = 0;
for (int i = 2; i <= 100; i++)
{
for (int j = 1; j <= i; j++)
{
if (i % j == 0)
{
sayac = sayac + 1;
}
}
if (sayac == 2)
{
adet = adet + 1;
Console.WriteLine(i);
}
sayac = 0;
}
Console.Write("0'dan 100'e kadar olan asal sayıların adedi={0}", adet);
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace asal_sayılar
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
int sayac=0, adet = 0;
for (int i = 2; i <= 100; i++)
{
for (int j = 1; j <= i; j++)
{
if (i % j == 0)
{
sayac = sayac + 1;
}
}
if (sayac == 2)
{
adet = adet + 1;
Console.WriteLine(i);
}
sayac = 0;
}
Console.Write("0'dan 100'e kadar olan asal sayıların adedi={0}", adet);
Console.ReadKey();
}
}
}
C# Console ile asal sayıları ve adedini bulan program
Reviewed by Abdulhamit Ekşioğlu
on
Ekim 31, 2014
Rating:
Hiç yorum yok: