By GokiSoft.com|
10:08 05/10/2021|
C Sharp
In dãy Fibonacci trong C# - Tìm dãy số Fibonacci - Lập trình C# - Loop trong C#
Cho chuỗi fibonaci sau
F(n) = f(n-1) + f(n-2)
F(0) = 1
F(1) = 1
Nhập vào số max -> thực hiện in ra các số fibonaci có giá trị < max
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
Phan Bạch Tùng Dương
2020-05-29 02:25:27
using System;
namespace Lession3
{
class DisplayFibonacci
{
static void Main(string[] args)
{
int f1 = 1, f2 = 1;
int max, f = 1;
Console.Write("Nhap so max : ");
max = int.Parse(Console.ReadLine());
Console.Write("Day so fibonacci tu -> {0} : 0 , 1 , 1 ", max);
for (int i = 0; f < max - f / 2; i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.Write(", {0} ", f);
}
Console.ReadKey();
}
}
}
Phí Văn Long
2020-05-20 05:24:28
using System;
namespace Fibonacci
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
int f1 = 1, f2 = 1;
int max, f = 1;
Console.WriteLine("nhap so max : ");
max = int.Parse(Console.ReadLine());
Console.Write("Day so fibonacci co gia tri < max : \n 0 , 1 , 1 , ");
for (int i = 0; f < max - f / 2; i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.Write(" {0} , ", f);
}
}
}
}
lê văn phương
2020-05-20 02:18:28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fibonacci
{
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
int f1 = 1, f2 = 1;
int max, f = 1;
Console.Write("Nhập số max : ");
max = int.Parse(Console.ReadLine());
Console.Write("Dãy số fibonaci từ -> {0} : 0 , 1 , 1 ", max);
for (int i = 0; f < max - f / 2; i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.Write(", {0} ", f);
}
Console.ReadKey();
}
}
}
Trần Ngọc Hải
2020-05-19 16:55:02
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fibonaci
{
class Program
{
static void Main(string[] args)
{
int f1 = 1, f2 = 1;
int max, f = 1;
Console.WriteLine("Nhap Max : ");
max = int.Parse(Console.ReadLine());
Console.Write("Day Fibonaci có giá trị < max : \n 0 , 1 , 1 , ");
for (int i = 0; f < max - f / 2; i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.Write(" {0} , ", f);
}
}
}
}
Trần Anh Quân
2020-05-19 15:28:31
using System;
namespace fibonanci
{
class Program
{
static void Main(string[] args)
{
int f1 = 1, f2 = 2;
int max, f = 1;
Console.WriteLine("Nhap max:");
max = int.Parse(Console.ReadLine());
Console.Write("Day so F tu -> {0} : 0 , 1 , 1 ", max);
for(int i = 0; f < max - f / 2; i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.WriteLine("{0},", f);
}
}
}
}
Đường Thanh Bình
2020-05-19 14:10:22
using System;
using System.Text;
namespace Lession2
{
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
int f1 = 1, f2 = 1;
int max, f = 1;
Console.WriteLine("Nhập số max : ");
max = int.Parse(Console.ReadLine());
Console.Write("Day so fibonaci tu -> {0} : 0 , 1 , 1 ", max);
for (int i = 0; f < max - f / 2; i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.Write(", {0} ", f);
}
Console.ReadKey();
}
}
}
Lê Minh Bắc
2020-05-19 04:16:25
using System;
namespace Lession2
{
class Fobinaci
{
static void Main(string[] args)
{
int f1 = 1, f2 = 1;
int max, f = 1;
Console.Write("nhap so max : ");
max = int.Parse(Console.ReadLine());
Console.Write("Day so fibonaci tu -> {0} : 0 , 1 , 1 ",max);
for (int i = 0; f < max - f / 2; i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.Write(", {0} ", f);
}
Console.ReadKey();
}
}
}
Trần Mạnh Dũng
2020-05-18 08:21:15
using System;
namespace T1907A
{
class Program
{
static void Main(string[] args)
{
int f1 = 1, f2 = 1;
int max, f = 1;
Console.WriteLine("Enter max number: ");
max = int.Parse(Console.ReadLine());
Console.Write("Finbonaci < {0}: 0 , 1, 1", max);
for(int i=0;f < max-f/2 ;i++)
{
f = f1 + f2;
f1 = f2;
f2 = f;
Console.Write(", {0} ",f);
}
}
}
}
NguyenHuuThanh
2020-05-18 05:36:25
using System;
namespace Fibonacci
{
class Program
{
static void Main(string[] args)
{
int a = 1, b = 1;
int N;
Console.WriteLine("Nhap so :");
N = int.Parse(Console.ReadLine());
int sum = a + b;
while ( sum < N )
{
Console.Write(sum + ",");
a = b;
b = sum;
sum = a + b;
}
}
}
}
Thành Lâm
2020-05-18 05:01:43
Thanh Lam
using System;
public class Class1
{
public Class1()
{
static void Main(string[] args)
{
int f0 = 1, f1 = 1, fn, max;
Console.WriteLine("\nNhap vao so Fibonaci max: ");
int max = int.Parse(Console.ReadLine());
Console.WriteLine("\nDay Fibonaci\n");
Console.WriteLine(f0 + ", " + f1);
while (1)
{
fn = f0 + f1;
if(fn > max)
{
break;
}
Console.WriteLine(", " + fn);
f0 = f1;
f1 = fn;
}
}
}
}