Sort every suffix of a text, find the longest common prefix of neighbours, then search for a pattern by binary search and read off the longest repeat.
This interactive visualization needs JavaScript.