Let there may be x two-rupee coins in the bag.
Then No. of 5-rupee coins = 15 – x
Value of x two rupee coins = Rs 2x
Value of 5-rupee coins = Rs 5(15 – x)
According to question
⇒ 2x + 5 (15 – x) = 45
⇒ 2x + 75 – 5x = 45
⇒ 2x – 5x + 75 = 45
⇒ – 3x + 75 = 45
⇒ – 3x = 45 – 75
⇒ – 3x = – 30
⇒ x = -30/-3
⇒ x = 10
Hence, No. of 2-rupee coins = 10 and No. of 5-rupee coins = 15 – 10 = 5