Created
October 2, 2023 14:06
-
-
Save FromMeloriWithLove/0359b2566cc3b48121b0a58062f8ca30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. | |
DECLARE @start int = 0 | |
DECLARE @finish int = 5 | |
DECLARE @current int = @start | |
DECLARE @result nvarchar(500) = '' | |
WHILE @current < @finish | |
BEGIN | |
SET @result += '*' | |
SET @current += 1 | |
END | |
PRINT @result | |
2. | |
DECLARE @start int = 2 | |
DECLARE @finish int = 1000000 | |
WHILE @start <= @finish | |
BEGIN | |
DECLARE @prime_num bit = 1; | |
DECLARE @current int = 2; | |
WHILE @current <= SQRT(@start) | |
BEGIN | |
IF @start % @current = 0 | |
BEGIN | |
SET @prime_num = 0 | |
BREAK | |
END | |
SET @current += 1 | |
END | |
IF @prime_num = 1 | |
PRINT CAST(@start AS int) | |
SET @start += 1 | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment