清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
CREATE FUNCTION CheckPrimeNumber(@No BIGINT) RETURNS TINYINT AS BEGIN IF @No <= 1 RETURN 0 DECLARE @maxV BIGINT, @Index BIGINT SET @maxV = @No - 1 SET @Index = 2 WHILE @Index < @maxV BEGIN DECLARE @maxV2 BIGINT, @Index2 BIGINT SET @maxV2 = @maxV SET @Index2 = @Index WHILE @Index2 < @maxV2 BEGIN IF @Index2 * @Index = @No RETURN 0 SET @Index2 = @Index2 + 1 END SET @Index = @Index + 1 END RETURN 1 END GO SELECT dbo.CheckPrimeNumber(13) -- 返回值1,表示素数,0表示非素数。