Basically I take my number p, square root it, Rd. Up to the nearest prime, then the next prime greater than that -1= largest prime gap below p.
This works because the greatest number of composites between two primes occurs when factors are not combined. So what could have been two composites is actually just one, like 15=3x5. To create the greatest possible number of composites I start at 2 not 0. 0 has an infinite number of prime factors, and so the greatest gap between the next repeat will occur after 0. Starting with the smallest composite which is NOT combined factors, I move up. Deleting all numbers factorable by primes less than the square root. The first time I attain TWO primes is when I reach the second prime after the square root. So this -1 is the gap required to create two non-composites with greatest possible occurrence of composites.
Largest prime gap <p =Rd. Up to second nearest prime -1.
"Time not important. Only life important." - The Fifth Element 1997