Kendisi hariç pozitif tam sayı bölenlerinin toplamı kendisinden büyük olan sayıya zengin sayı denir.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication46
{
class Program
{
static void Main(string[] args)
{
int tpl = 0;
for (int i = 21; i <=1000 ; i++)
{
for (int j = 1; j <i ; j++)
{
if (i%j==0)
{
tpl += j;
}
}
if (i > tpl)
{
Console.WriteLine("{0} sayısı kıttır", i);
}
else if (i < tpl)
{
Console.WriteLine("{0} sayısı zengindir", i);
}
tpl = 0;
}
}
}
}
En Küçük Pozitif Tek Kıt Sayı
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication46
{
class Program
{
static void Main(string[] args)
{
int tpl = 0;
for (int i = 1; i <=1000 ; i++)
{
for (int j = 1; j <i ; j++)
{
if (i%j==0)
{
tpl += j;
}
}
if (i > tpl)
{
Console.WriteLine("{0} sayısı kıttır", i);
}
else if (i < tpl && i%2==1)
{
Console.WriteLine("{0} sayısı zengindir", i);
}
tpl = 0;
}
}
}
}
0 Yorumlar