We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
DECLARE @N INT = 1000;
DECLARE @i INT = 2;DECLARE @output NVARCHAR(MAX) = '';
WHILE @i <= @N
BEGIN IF (@i % 2 = 0)
BEGIN SET @output = @output + CAST(@i AS NVARCHAR) + '&'; END SET @i = @i + 1; END
SET @output = LEFT(@output, LEN(@output) - 1);
PRINT @output;
What is the problem in my this code?
Cookie support is required to access HackerRank
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 @N INT = 1000; DECLARE @i INT = 2;DECLARE @output NVARCHAR(MAX) = '';
WHILE @i <= @N BEGIN IF (@i % 2 = 0) BEGIN SET @output = @output + CAST(@i AS NVARCHAR) + '&'; END SET @i = @i + 1; END SET @output = LEFT(@output, LEN(@output) - 1); PRINT @output; What is the problem in my this code?