C Program untuk Mencetak Segitiga Menggunakan Rekursi di JavaScript

<script>
 
// JavaScript code to demonstrate star pattern
 
    // function to print a row
    function printn(num) {
        // base case
        if (num == 0)
            return;
        document.write("* ");
 
        // recursively calling printn()
        printn(num - 1);
    }
 
    // function to print the pattern
    function pattern(n , i) {
        // base case
        if (n == 0)
            return;
        printn(i);
        document.write("<br/>");
 
        // recursively calling pattern()
        pattern(n - 1, i + 1);
    }
 
    // Driver code
     
 
        var n = 5;
        pattern(n, 1);
 
// This code is contributed by aashish1995
 
</script>
Aman Dixit