koding C# Bilanagn Pima dan Ganjil
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HIdayat_MAulana_141100088
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Nama : hidayat maulana");
Console.WriteLine("BP : 141100088");
Console.WriteLine("");
Console.WriteLine("MUsukan
blangan prima dan genap anda :");
int i, n, fakt;
fakt = 0;
for (i = 2; i <= 50; i++)
{
for (n = 2; n <= Math.Sqrt(i); n++)
{ if (n % i == 0)fakt++; }
if (fakt == 0)
{
Console.WriteLine("Bilangan
:" + i);
Console.WriteLine("");
Console.WriteLine("BILANGAN GANJIL PRIMA :");
}
for (i = 3; i <= 50; i++)
{
fakt = 0;
for (n = 2; n <= Math.Sqrt(i); n++)
{ if (i % n == 0)fakt++; }
if (fakt == 0)
{ Console.WriteLine("Bilangan
:" + i); }
} Console.ReadLine();
}
}
}
}
0 komentar: