fork download
  1. //276
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a[31];
  8. a[1]=1;
  9. a[2]=1;
  10. for(int i=3; i<=30;i++){
  11. a[i] = a[i/2] + a[i-2];
  12.  
  13. }
  14. for(int i=1;i<=30;){
  15. cout<<i<<" "<<" element of the sequence = ";
  16. cout<<a[i]<<endl;
  17. i++;
  18. }
  19.  
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3456KB
stdin
30
stdout
1  element of the sequence = 1
2  element of the sequence = 1
3  element of the sequence = 2
4  element of the sequence = 2
5  element of the sequence = 3
6  element of the sequence = 4
7  element of the sequence = 5
8  element of the sequence = 6
9  element of the sequence = 7
10  element of the sequence = 9
11  element of the sequence = 10
12  element of the sequence = 13
13  element of the sequence = 14
14  element of the sequence = 18
15  element of the sequence = 19
16  element of the sequence = 24
17  element of the sequence = 25
18  element of the sequence = 31
19  element of the sequence = 32
20  element of the sequence = 40
21  element of the sequence = 41
22  element of the sequence = 50
23  element of the sequence = 51
24  element of the sequence = 63
25  element of the sequence = 64
26  element of the sequence = 77
27  element of the sequence = 78
28  element of the sequence = 95
29  element of the sequence = 96
30  element of the sequence = 114