Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace NumerosPrimos
- {
- class MainClass
- {
- public static void Main (string[] args)
- {
- Console.WriteLine ("Ingrese la cantidad de números primos generar");
- String cantnumeros = Console.ReadLine();
- int cant = Convert.ToInt32 (cantnumeros);
- int contador = 1;
- int primo = 2;
- int divisor = 2;
- while (contador <= cant) {
- if (primo % divisor == 0) {
- if (primo == divisor) {
- Console.Write(primo + ", ");
- contador++;
- }
- divisor = 2;
- primo++;
- }
- else
- divisor++;
- }
- Console.ReadKey ();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement