1. Deret Fibonaci
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[]
args)
{
int x = 1, y = 1, z = 1;
Console.Write("jumlah
bilangan Fibonasi yang ingin ditampilkan =");
int jumlah =
Convert.ToInt32(Console.ReadLine());
for (int i = 0; i <
jumlah; i++)
{
Console.Write(z +
" ");
z = x + y;
x = y;
y = z;
}
}
}
}
2. Deret
Bergoyang
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[]
args)
{
int x = 1, y = 0, z =
-1, a=-1;
Console.Write("jumlah Deret bergoyang yang ingin ditampilkan
=");
int jumlah =
Convert.ToInt32(Console.ReadLine());
for (x = 1; x <=
jumlah; x++)
{
{
Console.Write(x
+ " , " + z + " , ");
z = z + a;
x = x + y;
}
}
}
}
}
No comments:
Post a Comment