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.
Draw The Triangle 1
Draw The Triangle 1
Sort by
recency
|
1120 Discussions
|
Please Login in order to post a comment
SOLUTION FOR MySQL:
SQL Server
why the following is wrong as it achieve whtat we need to achieve declare @i int=20,@star nvarchar(max)=''; while @i>=1 begin select @star=replicate('*',@i) print(@star) select @i=@i-1
end
-- MySQL WITH RECURSIVE pattern AS ( SELECT 1 AS id UNION ALL SELECT id + 1 FROM pattern WHERE id < 20 ) SELECT REPEAT('* ', id) AS stars FROM pattern order by id DESC;
P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):
Write a query to print the pattern P(20).