using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

public partial class UserDefinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]

    public static double FactClr(double x) 
    {
        double y;
        y = 1.0;

        while(x > 1.0) 
        {
          y = y * x;
          x = x - 1;
        }
        return y;
    }
};

