Calculate money placed in boxes after N days based on given conditions | Function to find total money placed in the box ; Number of complete weeks ; Remaining days in the last week ; Input ; Function call to find the total money placed
function totalMoney ( N ) { let CompWeeks = Math . floor ( N / 7 ) ; let RemDays = N % 7 ; let X = 28 * CompWeeks + 7 * Math . floor ( ( CompWeeks * ( CompWeeks - 1 ) / 2 ) ) ; let Y = RemDays * Math . floor ( ( RemDays + 1 ) / 2 ) + CompWeeks * RemDays ; let cost = X + Y ; document . write ( cost , ' ' ) ; } let N = 15 ; totalMoney ( N ) ;