[Off] [Desafio] Nъmeros primos
#2

C#
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Testing
{
    class Program
    {
        static void Main(string[] args)
        {
            int num;
            
            Console.Write("Insira o numero a ser verificado: ");
            num = Convert.ToInt16( Console.ReadLine() );

            for(int i = 2; i <= num; i++){
                if (i != 2 && i != 3 && i != 5 && i != 7){
                    if ((i % 2 > 0) && (i % 3 > 0) && (i % 5 > 0) && (i % 7 > 0)){
						Console.WriteLine("{0} й primo!", i);   
                    }
                }
                else {
                    Console.WriteLine("{0} й primo!", i);
                }
            }
            Console.ReadKey();
        }
    }
}
Код:
100 -
2,3,5,7, 11,13,17,19,23,29,31,37,41,43,47, 53,59, 
61,67,71,73,79, 83,89 e 97.
Reply


Messages In This Thread
[Desafio] Nъmeros primos - by JoaoPedro - 13.03.2014, 16:11
Re: [Desafio] Nъmeros primos - by Sky™ - 13.03.2014, 18:29
Re: [Desafio] Nъmeros primos - by WLSF - 13.03.2014, 18:57
Re: [Desafio] Nъmeros primos - by Gii - 13.03.2014, 18:57
Re: [Desafio] Nъmeros primos - by Sky™ - 13.03.2014, 19:09
Re: [Desafio] Nъmeros primos - by WLSF - 13.03.2014, 19:14
Re: [Desafio] Nъmeros primos - by Douglas_prt - 13.03.2014, 19:34
Re: [Desafio] Nъmeros primos - by JoaoPedro - 13.03.2014, 19:41
Re: [Desafio] Nъmeros primos - by Sky™ - 13.03.2014, 20:27
Re: [Desafio] Nъmeros primos - by JoaoPedro - 13.03.2014, 20:31

Forum Jump:


Users browsing this thread: 1 Guest(s)