• Create Account

### #Actualalvaro

Posted 16 October 2012 - 09:32 AM

Let's call F(a,b) = x. I put your examples into a table, I observed that F(n-1,n) are triangular numbers, and it was simple manipulation from there. I verified the result with this command line:
> perl -e 'for ($b=1;$b<6; ++$b) {for ($a=$b-1;$a>=0; $a--){$x = $b*($b+1)/2-$a-1; print "$a - $b --->$x\n"}}'
0 - 1 ---> 0
1 - 2 ---> 1
0 - 2 ---> 2
2 - 3 ---> 3
1 - 3 ---> 4
0 - 3 ---> 5
3 - 4 ---> 6
2 - 4 ---> 7
1 - 4 ---> 8
0 - 4 ---> 9
4 - 5 ---> 10
3 - 5 ---> 11
2 - 5 ---> 12
1 - 5 ---> 13
0 - 5 ---> 14

### #1alvaro

Posted 16 October 2012 - 09:31 AM

Let's call F(a,b) = x. I made put your examples into a table, I observed that F(n-1,n) are triangular numbers, and it was simple manipulation from there. I verified the result with this command line:
> perl -e 'for ($b=1;$b<6; ++$b) {for ($a=$b-1;$a>=0; $a--){$x = $b*($b+1)/2-$a-1; print "$a - $b --->$x\n"}}'
0 - 1 ---> 0
1 - 2 ---> 1
0 - 2 ---> 2
2 - 3 ---> 3
1 - 3 ---> 4
0 - 3 ---> 5
3 - 4 ---> 6
2 - 4 ---> 7
1 - 4 ---> 8
0 - 4 ---> 9
4 - 5 ---> 10
3 - 5 ---> 11
2 - 5 ---> 12
1 - 5 ---> 13
0 - 5 ---> 14

PARTNERS