Triangular number


#1

write a program to print the nth triangular number.where n is input given by the user


#2

import java.uitl.*;
public class TriangularNumber {

public static void main(String[] args) {

   int number ;

Scanner s=new Scanner(System.in);
number=s.nextInt();
int triangular = 0;
for(int i = 1;i<=number;i++) {
triangular = triangular + i;
}
System.out.println("Triangular Number for “+number+” is "+triangular);
}

}