primtenyezos_felbontas/primtenyezo/Program.cs

29 lines
760 B
C#
Raw Normal View History

2025-01-17 11:32:04 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace primtenyezo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Prímtényezős felbontás");
Console.Write("Pozitív egész szám: ");
int szam = Convert.ToInt32(Console.ReadLine());
int oszto = 2;
while (szam > 1) {
while (szam % oszto == 0) {
Console.WriteLine("{0}\t | \t{1}", szam, oszto);
szam = szam / oszto;
}
oszto++;
}
Console.WriteLine("{0} \t |", szam);
Console.ReadKey();
}
}
}