[ create a new paste ] login | about

Link: http://codepad.org/bJM7GxiV    [ raw code | output | fork ]

C, pasted on Oct 18:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
#define r 2.0
#define h 0.0005
#define N0 100
#define T_END 20
int main() {
  double N;
  int t;
  N = N0;
  for (t = 0; t < T_END; t += 1) {
    printf("%d : %.1f\n", t, N);
    N += (r - h * N) * N;
  }
  return 0;
}
/* end */


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0 : 100.0
1 : 295.0
2 : 841.5
3 : 2170.4
4 : 4155.9
5 : 3832.0
6 : 4153.9
7 : 3834.2
8 : 4152.0
9 : 3836.4
10 : 4150.2
11 : 3838.5
12 : 4148.4
13 : 3840.5
14 : 4146.8
15 : 3842.5
16 : 4145.1
17 : 3844.4
18 : 4143.5
19 : 3846.2


Create a new paste based on this one


Comments: