Advertisement
Guest User

Trabajo N°0 Ejercicio 8

a guest
Aug 17th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TP0_Ejerc8
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int suma = 0;
  14.             int impar = 1;
  15.             int numero = 1;
  16.             while (impar <= 100)
  17.             {
  18.                 suma += numero;
  19.                 impar++;
  20.                 numero += 2;
  21.             }
  22.             Console.WriteLine("La suma de los primeros 100 numeros naturales impares es " + suma);
  23.             Console.ReadKey();
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement