您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

判断质数

2024/3/17 13:55:29发布33次查看
判断整数是否为质数 无 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 b
判断整数是否为质数 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 goselect dbo.checkprimenumber(13) -- 返回值1,表示素数,0表示非素数。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product