Menghitung Deret barisan Bilangan C# Posted by Unknown on January 13, 2015 Get link Facebook X Pinterest Email Other Apps using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MODUL3_5 { class Program { static void Main(string[] args) { Console.WriteLine("Hitung 3 + 6 + 9 +...+ N"); Console.WriteLine("========================"); Console.WriteLine(); int hasil = 0; int a = 3; int b=0; int temp = 0; int bilangan; Console.Write("Jumlah Bilangan (min.1) = "); bilangan = Convert.ToInt32(Console.ReadLine()); for (int i = 1; i <= bilangan; i++) { b+= a; temp += b; hasil = temp; } Console.WriteLine(); Console.WriteLine("Hasil = {0} ", hasil); Console.ReadKey(); } } } Comments
Comments
Post a Comment