How to count lines of cout?

Pages: 123
snipping tool? I use that one mostly.
Last edited on
Thanks everyone who shed light on the problem. Especially to jonnin. I'm sorry for being mix up with 115 and 155 and having noticed it. One number confused all system
Hmm. There's a closed-form expression, in fact. Done by tracing back the dependencies in my iterative formula. However, there must be a quicker argument for choosing n from 2n ...

vn = 2nCn

e.g.
v1 = 2C1 = 2
v2 = 4C2 = 6
v3 = 6C3 = 20
etc.

The ratio of successive terms is vn/vn-1 = 2(2n-1)/n

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;

int main()
{
   unsigned long long v = 1;
   for ( int n = 1; n <= 31; n++ )      // overflow danger for higher
   {
      v = v * 2 * ( 2 * n - 1 ) / n;
      cout << "v" << n << ": " << v << '\n';
   }
}


v1: 2
v2: 6
v3: 20
v4: 70
v5: 252
v6: 924
v7: 3432
v8: 12870
v9: 48620
v10: 184756
v11: 705432
v12: 2704156
v13: 10400600
v14: 40116600
v15: 155117520
v16: 601080390
v17: 2333606220
v18: 9075135300
v19: 35345263800
v20: 137846528820
v21: 538257874440
v22: 2104098963720
v23: 8233430727600
v24: 32247603683100
v25: 126410606437752
v26: 495918532948104
v27: 1946939425648112
v28: 7648690600760440
v29: 30067266499541040
v30: 118264581564861424
v31: 465428353255261088
very nice work. A much better form than mine :(
Last edited on
Topic archived. No new replies allowed.
Pages: 123