The difficulty
2 red beads are put in between every 2 blue beads. There are N blue beads. After taking a look at the plan listed below exercise the variety of red beads.
@ @@ @ @@ @ @@ @ @@ @ @@ @
Implement count_red_beads( n)
( countRedBeads( n)
) so that it returns the variety of red beads.
If there are less than 2 blue beads return 0.
The option in C
Choice 1:
int countRedBeads( n) {
if( n<.
int countRedBeads (int n);.
Test( sample_tests, should_pass_all_the_tests_provided).
{
cr_assert_eq( countRedBeads( 0 ), 0);.
cr_assert_eq( countRedBeads( 1 ), 0);.
cr_assert_eq( countRedBeads( 3 ), 4);.
cr_assert_eq( countRedBeads( 5 ), 8);.
}