Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace EDTP02
- {
- class Program
- {
- static void Main(string[] args)
- {
- int suma =0,num ;
- Stack<int> pilaP = new Stack<int>();
- do
- {
- Console.WriteLine("Ingrese un numero positivo:");
- string stringnum = Console.ReadLine();
- num = int.Parse(stringnum);
- } while (num <= 0);
- for (int i = 1; i < num; i++)
- {
- if (num % i == 0)
- {
- pilaP.Push(i);
- suma += pilaP.Pop();
- }
- }
- if (suma == num)
- {
- Console.WriteLine("El numero ingresado es perfecto");
- }
- else
- {
- Console.WriteLine("El numero ingresado no es perfecto");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement