2 câu trả lời
program bai_giai;
uses crt;
var a:array[1..1000]of longint; n,i:longint;
begin
clrscr;
a[1]:=1;
a[2]:=1;
for i:=3 to 46 do a[i]:=a[i-1]+a[i-2];
write('nhap n:');readln(n);
write('so fibonaci thu n la: ',a[n]);
readln
end.
Program fibo_thun;
uses crt;
var n,f1,f2,f3:integer;
s,x:ansistring;
begin
writeln('Nhap so n'); read(n);
s:='11';
f1:=1;
f2:=1;
while length(s)<=n do
begin
f3:=f1+f2;
f1:=f2;
f2:=f3;
begin
str(f3,x);
s:=s+x;
end;
end;
write(s[n],' ',s);
end.
Câu hỏi trong lớp
Xem thêm