You are viewing a single comment's thread. Return to all comments →
DECLARE @POSSIBLEPRIME INT = 3 DECLARE @text NVARCHAR(MAX) = '2'
WHILE @POSSIBLEPRIME <= 1000 BEGIN DECLARE @Counter INT = 2 DECLARE @IsPRIME bit = 1 WHILE @Counter < @PossiblePrime BEGIN if @PossiblePrime % @Counter = 0 begin Set @IsPRIME = 0; break; end Set @Counter = @Counter + 1 END if @IsPRIME = 1 begin SET @text = @text + '&' + cast(@POSSIBLEPRIME as varchar) end SET @POSSIBLEPRIME = @POSSIBLEPRIME + 1 SET @IsPrime = 1 END
print @text
Seems like cookies are disabled on this browser, please enable them to open this website
Print Prime Numbers
You are viewing a single comment's thread. Return to all comments →
DECLARE @POSSIBLEPRIME INT = 3 DECLARE @text NVARCHAR(MAX) = '2'
WHILE @POSSIBLEPRIME <= 1000 BEGIN DECLARE @Counter INT = 2 DECLARE @IsPRIME bit = 1 WHILE @Counter < @PossiblePrime BEGIN if @PossiblePrime % @Counter = 0 begin Set @IsPRIME = 0; break; end Set @Counter = @Counter + 1 END if @IsPRIME = 1 begin SET @text = @text + '&' + cast(@POSSIBLEPRIME as varchar) end SET @POSSIBLEPRIME = @POSSIBLEPRIME + 1 SET @IsPrime = 1 END
print @text