CELKO - your code does not compile. Looks like some logic is missing in the case statement.
I don't get " SELECT fact FROM Factrorials WHERE @f = @n " I @f supposed to be a column or a variable?
I like the idea of it and the recommendation of storing calendar data in table.