Print Number Patterns – For Loop Patterns JS

Print Number Patterns – For Loop Patterns JS

Table of Contents

Pattern 1

01 
01 02 
01 02 03 
01 02 03 04 
01 02 03 04 05
				
					<script type="litespeed/javascript">var a;var n=prompt("Enter a number for the no. of rows in a pattern");for(var i=1;i<=n;i++){for(var j=1;j<=i;j++){document.write("0"+j+" ")}
document.write("<br />")}</script> 
				
			

Pattern 2

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
				
					<script type="litespeed/javascript">for(i=1;i<=5;i++){for(j=1;j<=i;j++){document.write(j);if(j==i)continue;else document.write(' ')}
document.write('<br />')}</script>
				
			

Pattern 3

1   2  3  4  5 
6   7  8  9 10 
11 12 13 14 15
				
					<script type="litespeed/javascript">a=0;for(j=1;j<=3;j++){for(i=1;i<=5;i++){document.write(a+i+" ")}document.write("<br>");a=a+5}</script>
				
			

Pattern 4

1  2  3  4  5
 
2  4  6  8 10
 
3  6  9 12 15
				
					<script type="litespeed/javascript">a=1;for(j=1;j<=3;j++){for(i=1;i<=5;i++){document.write(a*i+" ")}document.write("<br>");a=a+1}</script>
				
			

Pattern 5

1   
2   1   
3   2   1   
4   3   2   1   
5   4   3   2   1
				
					<script type="litespeed/javascript">for(i=1;i<=5;i++){for(j=i;j>=1;j--){document.write(j+" ")}document.write("<br>")}</script>
				
			

Pattern 6

5   4   3   2   1   
4   3   2   1   
3   2   1   
2   1   
1 
				
					<script type="litespeed/javascript">for(i=5;i>=1;i--){for(j=i;j>=1;j--){document.write(j+" ")}document.write("<br>")}</script>
				
			

Pattern 7

              1  
           1  2  
        1  2  3  
     1  2  3  4  
  1  2  3  4  5
				
					<script type="litespeed/javascript">for(i=1;i<=5;i++){for(k=4;k>=i;k--){document.write(" ")}for(j=1;j<=i;j++){document.write(j+" ")}document.write("<br>")}</script>
				
			

Pattern 8

               1  
            2  1  
         3  2  1  
      4  3  2  1  
   5  4  3  2  1 
				
					<script type="litespeed/javascript">for(i=1;i<=5;i++){for(k=1;k<=5-i;k++){document.write(" ")}for(j=i;j>=1;j--){document.write(j+" ")}document.write("<br>")}</script>
				
			

Take Your Free Live Demo Class Now

Enter Your DETAILS BELOW

To Get Complete Information or We Will Call You

We Will Send You the Course Fees Details In Below Number

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

Enter Your DETAILS BELOW TO take

free demo class