Skip to content

Commit

Permalink
Proposta de Solução desafio-02. (#1059)
Browse files Browse the repository at this point in the history
* Proposta de Solução desafio-02.

* Efetuadas correções sugeridas

* Removendo op-desafios.sln
  • Loading branch information
ronaldofas authored Jun 26, 2024
1 parent 4651b4d commit ebcfe3b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
33 changes: 33 additions & 0 deletions desafio-02/ronaldofas/csharp/primos/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;

class Program{

public static void Main(string[] args){
ListarPrimos();
}

static void ListarPrimos()
{
Console.WriteLine("Imprime números primos de 1 a 10000");
for(int i=1;i<=10000;i++)
{
if(EhPrimo(i))
{
Console.WriteLine(i);
}
}
}

static bool EhPrimo(int n)
{
if(n <= 1) return false;
int count = 0;
for(int i = 1; i <= n; i++)
{
if(n % i == 0) count++;

if (count > 2) return false;
}
return true;
}
}
10 changes: 10 additions & 0 deletions desafio-02/ronaldofas/csharp/primos/primos.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>

0 comments on commit ebcfe3b

Please sign in to comment.