Mary has given John two sticks of lengths a
and b
respectively, where a
and b
are positive integers.
John is very curious.
He would like to know how many triangles with integer perimeter can be formed, by having one additional side.
Please help him find it out.
(This is my first time composing this kind of stupid stories in coding problems, so forgive me if it is too stupid.)
Specs
- Given two integers
a
andb
, find the number of triangles with integer perimeter that can be formed, by having one additional side.
Details
- Congruent triangles are congruent.
- Flat triangles are flat out uncounted.
- Zero-sided triangles are counted zero times.
Scoring
This is code-golf. Shortest solution in bytes wins.
Testcases
a b output
1 2 1
3 3 5
9 7 13