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 TP00EJ9
- {
- class Program
- {
- //PROGRAMA QUE DETERMINE SI UN NUMERO ES PERFECTO
- static void Main(string[] args)
- {
- int num;
- Console.Write("Ingrese un numero: ");
- num= int.Parse (Console.ReadLine());
- perfecto(num);
- Console.ReadKey();
- }
- public static void perfecto (int num)
- {
- int suma = 0;
- for (int i = 1; i < num; i++)
- {
- if (num % i== 0) // % resto
- {
- suma = suma + i;
- }
- }
- if (suma == num)
- {
- Console.WriteLine("");
- Console.WriteLine(" El Numero es perfecto");
- }
- else
- {
- Console.WriteLine("");
- Console.WriteLine("El Numero no es perfecto");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement