Calculate the total cost of a car rental given the number of rental days and applicable discounts.
A car rental company offers discounts based on the duration of the rental: - The daily rental cost is $40. - For rentals of 7 days or more, a $50 total discount is offered. - For rentals of 3 or more days, a $20 total discount is offered. Write a function `rental_cost` to calculate the total rental cost for a given number of days `d`. ### Parameters - `d` (int): The number of days the car is rented. ### Return Value - Returns an integer representing the total cost of the car rental for `d` days after considering any relevant discounts. ### Examples ```python # A one-day rental costs $40 rental_cost(1) # 40 # A four-day rental without long-term discounts costs $40*4 - $20 rental_cost(4) # 140 # An eight-day rental with week-long discount costs $40*8 - $50 rental_cost(8) # 270 ```