]]> ]]>

Факториал в SQL

Пример для версий Microsoft SQL Server 2005
declare @max_n tinyint = 20
;with t as (
   select 1 as n, convert(bigint,1) as f
   union all
   select n+1, f*(n+1) from t
   where n < @max_n
   
)
select convert(varchar,n)+'! = '+convert(varchar(32),f)+', ' 
from t as [text] 
FOR XML PATH ('')

Комментарии

]]>

blog comments powered by Disqus

]]>

Работа программистам