You are viewing a single comment's thread. Return to all comments →
DECLARE @lim int = 1000; DECLARE @counter int = 3; DECLARE @primes table(number int); INSERT INTO @primes VALUES (2) WHILE @counter <= @lim BEGIN if not exists (select top 1 1 from @primes where @counter % number = ``0) INSERT into @primes VALUES(@counter) SET @counter = @counter + 2 -- only checking odd numbers END SELECT STRING_AGG(number,'&') FROM @primes;
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 →