SlideShare a Scribd company logo
1 of 2
Download to read offline
import java.util.*;
public class NaturalNumberTriangle {
public static void main(String args[]) {
int rows, i, j, count = 1, star = 0;
Scanner in = new Scanner(System.in);
System.out.println("Enter number of rows in pattern");
rows = in.nextInt();
for (i = 1; i <= rows; i++) {
for (j = 1; j <= i; j++) {
System.out.print(count + " ");
count++;
}
System.out.print(" ");
}
}
}
Solution
import java.util.*;
public class NaturalNumberTriangle {
public static void main(String args[]) {
int rows, i, j, count = 1, star = 0;
Scanner in = new Scanner(System.in);
System.out.println("Enter number of rows in pattern");
rows = in.nextInt();
for (i = 1; i <= rows; i++) {
for (j = 1; j <= i; j++) {
System.out.print(count + " ");
count++;
}
System.out.print(" ");
}
}
}

More Related Content

More from info30292

Rutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdfRutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdf
info30292
 
Process improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdfProcess improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdf
info30292
 
In above scenarion Animator class,Actor pikachu=new Actor (picka.pdf
In above scenarion Animator class,Actor pikachu=new Actor (picka.pdfIn above scenarion Animator class,Actor pikachu=new Actor (picka.pdf
In above scenarion Animator class,Actor pikachu=new Actor (picka.pdf
info30292
 
From psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdfFrom psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdf
info30292
 
Check listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdfCheck listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdf
info30292
 
Antidiuretic hormone is important inA. bodys water balance.Ant.pdf
Antidiuretic hormone is important inA. bodys water balance.Ant.pdfAntidiuretic hormone is important inA. bodys water balance.Ant.pdf
Antidiuretic hormone is important inA. bodys water balance.Ant.pdf
info30292
 
1.playing audio in javaJava sound API(package javax.sound) support.pdf
1.playing audio in javaJava sound API(package javax.sound) support.pdf1.playing audio in javaJava sound API(package javax.sound) support.pdf
1.playing audio in javaJava sound API(package javax.sound) support.pdf
info30292
 

More from info30292 (20)

Rutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdfRutherford model of atom1) The electron cloud of the atom does n.pdf
Rutherford model of atom1) The electron cloud of the atom does n.pdf
 
Raising the pH will increase the basicity of the solution.Since su.pdf
Raising the pH will increase the basicity of the solution.Since su.pdfRaising the pH will increase the basicity of the solution.Since su.pdf
Raising the pH will increase the basicity of the solution.Since su.pdf
 
Process improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdfProcess improvementThe chance for development to either operating.pdf
Process improvementThe chance for development to either operating.pdf
 
Net operating assets = operating assets-operating liabilitiesNet o.pdf
Net operating assets = operating assets-operating liabilitiesNet o.pdfNet operating assets = operating assets-operating liabilitiesNet o.pdf
Net operating assets = operating assets-operating liabilitiesNet o.pdf
 
In above scenarion Animator class,Actor pikachu=new Actor (picka.pdf
In above scenarion Animator class,Actor pikachu=new Actor (picka.pdfIn above scenarion Animator class,Actor pikachu=new Actor (picka.pdf
In above scenarion Animator class,Actor pikachu=new Actor (picka.pdf
 
HNO3 is a strong acid pH = -log[H+] = -log[0.05] = 1.3p.pdf
HNO3 is a strong acid  pH = -log[H+] = -log[0.05] = 1.3p.pdfHNO3 is a strong acid  pH = -log[H+] = -log[0.05] = 1.3p.pdf
HNO3 is a strong acid pH = -log[H+] = -log[0.05] = 1.3p.pdf
 
From psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdfFrom psychological and cognitive perspectives, there are two basic b.pdf
From psychological and cognitive perspectives, there are two basic b.pdf
 
Formatting and code conversion occurs in the Presentation layer of t.pdf
Formatting and code conversion occurs in the Presentation layer of t.pdfFormatting and code conversion occurs in the Presentation layer of t.pdf
Formatting and code conversion occurs in the Presentation layer of t.pdf
 
Correct answer is option A. As epistasis occurs when the effect of o.pdf
Correct answer is option A. As epistasis occurs when the effect of o.pdfCorrect answer is option A. As epistasis occurs when the effect of o.pdf
Correct answer is option A. As epistasis occurs when the effect of o.pdf
 
Cloud computingIt is a kind of net based computing that gives sha.pdf
Cloud computingIt is a kind of net based computing that gives sha.pdfCloud computingIt is a kind of net based computing that gives sha.pdf
Cloud computingIt is a kind of net based computing that gives sha.pdf
 
Check listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdfCheck listpolicy to be implemented for having controls for purchasi.pdf
Check listpolicy to be implemented for having controls for purchasi.pdf
 
ans C it is a process of forming diazo compund .pdf
                     ans C it is  a process of forming diazo compund  .pdf                     ans C it is  a process of forming diazo compund  .pdf
ans C it is a process of forming diazo compund .pdf
 
Antidiuretic hormone is important inA. bodys water balance.Ant.pdf
Antidiuretic hormone is important inA. bodys water balance.Ant.pdfAntidiuretic hormone is important inA. bodys water balance.Ant.pdf
Antidiuretic hormone is important inA. bodys water balance.Ant.pdf
 
Al has metallic bonding while CHCl3 has dipole-dipole forces.Since.pdf
Al has metallic bonding while CHCl3 has dipole-dipole forces.Since.pdfAl has metallic bonding while CHCl3 has dipole-dipole forces.Since.pdf
Al has metallic bonding while CHCl3 has dipole-dipole forces.Since.pdf
 
Add warm water to dissolve the KBr which is very soluble. This would.pdf
Add warm water to dissolve the KBr which is very soluble. This would.pdfAdd warm water to dissolve the KBr which is very soluble. This would.pdf
Add warm water to dissolve the KBr which is very soluble. This would.pdf
 
14. b. effector15. c. negative effector16. a. the nerve cells sl.pdf
14. b. effector15. c. negative effector16. a. the nerve cells sl.pdf14. b. effector15. c. negative effector16. a. the nerve cells sl.pdf
14. b. effector15. c. negative effector16. a. the nerve cells sl.pdf
 
1.playing audio in javaJava sound API(package javax.sound) support.pdf
1.playing audio in javaJava sound API(package javax.sound) support.pdf1.playing audio in javaJava sound API(package javax.sound) support.pdf
1.playing audio in javaJava sound API(package javax.sound) support.pdf
 
1. Not legible2. Touch and taste are the two senses interpreted by.pdf
1. Not legible2. Touch and taste are the two senses interpreted by.pdf1. Not legible2. Touch and taste are the two senses interpreted by.pdf
1. Not legible2. Touch and taste are the two senses interpreted by.pdf
 
1 The entry to convert liabilities to revenue.2 Appears in the lia.pdf
1 The entry to convert liabilities to revenue.2 Appears in the lia.pdf1 The entry to convert liabilities to revenue.2 Appears in the lia.pdf
1 The entry to convert liabilities to revenue.2 Appears in the lia.pdf
 
statistically significantSolution statistically significant.pdf
 statistically significantSolution statistically significant.pdf statistically significantSolution statistically significant.pdf
statistically significantSolution statistically significant.pdf
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 

Recently uploaded (20)

Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 

import java.util.; public class NaturalNumberTriangle { publi.pdf

  • 1. import java.util.*; public class NaturalNumberTriangle { public static void main(String args[]) { int rows, i, j, count = 1, star = 0; Scanner in = new Scanner(System.in); System.out.println("Enter number of rows in pattern"); rows = in.nextInt(); for (i = 1; i <= rows; i++) { for (j = 1; j <= i; j++) { System.out.print(count + " "); count++; } System.out.print(" "); } } } Solution import java.util.*; public class NaturalNumberTriangle { public static void main(String args[]) { int rows, i, j, count = 1, star = 0; Scanner in = new Scanner(System.in); System.out.println("Enter number of rows in pattern"); rows = in.nextInt(); for (i = 1; i <= rows; i++) { for (j = 1; j <= i; j++) { System.out.print(count + " ");