1 solutions

  • 0
    @ 2025-11-5 17:32:58

    C++ :

    #include<iostream>
    using namespace std;
    
    int main()
    {
    	int f[55]={0,0,1}, n;
    	cin >> n;
    	for(int i = 3; i <= n; i++) f[i] = f[i-1] + f[i-2]; 
    	
    	for(int i = 1; i <= n; i++)
    		if(i%2==0) cout << f[i] << ' ';
    	return 0;
    }
    

    Pascal :

    var i,n:integer;
     a:array[1..100] of integer;
    begin
    readln(n);
    a[1]:=0;
    a[2]:=1;
    for i:=3 to  n do
      begin
      a[i]:=a[i-1]+a[i-2];
    
      end;
    for i:=1 to n do
      if i mod 2=0 then write(a[i],' ');
    end.
    
    • 1

    Information

    ID
    18547
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By