Problem 43639. Counting candies

Created by Chaya N in Community

In a classroom of 'n' children, every even numbered child gets one big candy and every odd numbered child gets two small candies. Count the total number of candies 'x' that one should bring to the class.

For example, if there are n = 10 children in the class, the first child gets two candies, second child gets one candy, third child gets two candies and so on. Total number of candies required is x = 15.

Solution Stats

69.86% Correct | 30.14% Incorrect
Last solution submitted on Dec 03, 2018

Recent Solvers39

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!