Created
May 29, 2022 21:12
-
-
Save pmatos2000/ddc6b869c0d7716a1e81f839be103366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IEnumerable<int> GerarNumerosTriangulares(int n) | |
{ | |
for (int i = 1; i <= n; i++) | |
{ | |
var numero = i * (i + 1) / 2; | |
yield return numero; | |
} | |
} | |
foreach(var numero in GerarNumerosTriangulares(5)) | |
{ | |
Console.WriteLine(numero); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment