I'm so sorry for your loss op.
I think it would be good for us to know what type of relationship you have with your ex, for example was he abusive towards you, is he difficult to deal with now and in what way, or do you usually have a fairly reasonable relationship?
I agree with pp that you don't need to tell him anything if he's abusive or if he's difficult to deal with and you feel it might be harmful to your physical or emotional wellbeing to have that conversation with him.
What you could do is ask someone else to give him the information you think is important for him to know.
Or if you normally are amicable, I'd wait until you feel ready to speak to him about it and then do it in the way that feels right to you.
You could send a letter, a voice note, a text or a phone call. It's difficult news to get, but your wellbeing is what matters here so you get to do this in whatever way meets your needs right now or not do it at all if that's what you need.
Be gentle with yourself right now and give yourself time and grace while you grieve. You don't owe anyone else anything right now. 💐