Sort by

recency

|

5117 Discussions

|

  • + 0 comments
    1. n = int(input())
    2. for i in range(1,n+1):
    3. s="#"*i
    4. print(s.rjust(n))
    5. in python
  • + 0 comments
    1. n = int(input())
    2. for i in range(1,n+1):
    3. s="#"*i
    4. print((n-i)*" "+s)
    5. in python
  • + 0 comments

    python

    n = int(input())

    for i in range (1, n + 1): print(" " * (n - i) + "#" * i)

  • + 0 comments

    Here is my c++ implementation, you can watch the video here : https://youtu.be/4yntFcMY30U

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        int n;
        cin >> n;
        for(int i = 1; i <= n; i++) {
            string s(n-i, ' '), e(i, '#');
            cout << s + e << endl;
        }
    
        return 0;
    }
    
  • + 1 comment

    javascript

    function staircase(n) {
        for(let i = 1; i <= n; i++) {
            console.log(" ".repeat(n - i) + '#'.repeat(i))
        }
    }