C# :: Aufgabe #99 :: Lösung #5
12 Lösungen

#99
Zahlen von 1 bis 100 aufaddieren
Anfänger - C#
von Torbo
- 15.05.2015 um 14:38 Uhr

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Gauß { class Program { static void Main(string[] args) { int a = 100; for (int i = 0; i < 1; i++) { a = (a + 1)*a / 2; } Console.WriteLine(a); Console.ReadLine(); } } }
#5

von mattthias (260 Punkte)
- 20.08.2015 um 11:26 Uhr

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Onetimepad { class Program { static void Main(string[] args) { string input = Console.ReadLine(); int inputInt = Int32.Parse(input); Console.WriteLine((((Int32)Math.Pow(inputInt, 2)) + inputInt) / 2); Console.ReadLine(); } } }
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1