Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6381
@blackshadows 6329
@mb1973 5388
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3357
@KshamaGupta 3318
Complete Leaderboard
Lottery Money
Basic Accuracy: 25.62% Submissions: 12 Points: 1

There is a game "Choose a number and win money", in which, a person playing a game has to select a number N and he/she will be awarded some money in Rupees accordingly. Some of the observations of selecting a number N and money awarded(M) are:-

N: 1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24 ..........

M: 3   2   1   6   5   4   3   2   1   12   11   10   9     8     7      6      5     4     3    2     1    24  23  22...............

i.e. if you selects a number N=1,she gets M=Rs 3,if N=2,M=Rs 2,if N=3 ,M=Rs 1 and so on..

 

Example 1:

Input:
N = 30
Output:
16
Explanation:
As per the distribution,
you earn Rs 16.

 

 

Example 2:

Input:
N = 1
Output:
3
Explanation:
As per the distribution,
you earn Rs 3.

 

 

Your Task:

You don't need to read input or print anything. Your task is to complete the function totalMoney() which takes an integer N and returns total money.

 

Expected Time Complexity: O(log(N))
Expected Auxiliary Space: O(1)

 

Constraints:
1<=N<=109

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Lottery Money

Output Window