Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create question.md #172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions GeeksforGeeks/GeeksAndBalls/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Geek loves to play with balls. He decided to go to market and buy few more balls for himself. Seeing Geek's love for balls, the kind shopkeeper offers him twice the number of balls what Geek already have. He will only offer this if the number of balls Geek already have is not a multiple of 2.
Given an integer n representing the number of balls geek already have. Find out how many balls will be offered to him by the shopkeeper.

Example 1:
Input: N = 10
Output: 0
Explanation: As 10 is a multiple of 2 so Geek won't be offered any balls.

Example 2:
Input: N = 7
Output: 14
Explanation: As 7 is not a mutliple of 2 so the shopkeeper would offer him the ball equal to twice of 7 i.e. 14.

Your Task:

Complete the function countBalls() which takes an integer n as input and returns an integer representing the total number of balls Geek will be offered.

Expected Time Complexity: 0(1)
Expected Space Complexity: 0(1)
Constraints:
1<<n<-105