I agree with Rimvydas' approach.
And for performance concerns on CTEs on this particular problem, this gives all the years from 1753 to 9999 that have 3 Friday the thirteenths.
It runs in about 2 to 3 seconds on my small test machine.
with thirteen (thedate) as(
select cast('01/13/1753' as datetime) as thedate
union all
select DATEADD(mm, 1, thedate)
from thirteen
where thedate < '01/01/9999'
)
select year(thedate) yr,
count(*) cnt
from thirteen
where DATENAME(dw, thedate) = 'Friday'
group by year(thedate)
having count(*) = 3
OPTION (MAXRECURSION 0)