The ARIZAL¹ wrote in his Sefer, Shaar Ruach HaKodesh, exactly how many fasts are required in order to fix each sin as part of a person's TeShuva. The Hebrew work Tikkun means to fix.
If a person has the strength and willpower to fast from before sunrise until nightfall the number of times required, they can and should fast.
EMERGENCY BACK-DOOR RESCUE PLAN
— Replacing Doing Countless Fasts With Money Donated For Torah.
In this generation, most people find it very difficult to fast. Instead of Fasting, a person can donate the cost of daily eating towards the Torah teachings directly related to their sin. Some Sages have stated that it's best to fast at least 1 time (for 25 hours) and then replace the rest of the required fasts with donations (Tzedaka/Ma'aser/Chomesh).
How To Calculate?
If the cost of food for an average day is $5, a person would multiply this $5 by the number of fast days they need to fast for that sin.
WARNING!
THIS DOES NOT MAKE SINNING PERMISSIBLE, But Rather Is There To Make A TIKKUN For The Past Mistakes.
The Arizal's prescribed fasts required for Tikkun:
Eating without a Blessing: 3 Fasts
Intimacy with Unmarried Jewish Woman: 40 Fasts
Intimacy with a woman who is Niddah: 82 Fasts
Wasting Seed: 84 Fasts
Homosexuality: 233 Fasts
Intimacy w/ Goya: 216 Fasts