Program to calculate the value of triangular number
class P6
{
public static void main(String args[])
{
int n , tri_num ;
n = 6;
tri_num = n * (n+1) / 2 ;
System.out.println("The value of the triangular number "+n+" is "+tri_num);
}
}
class P6
{
public static void main(String args[])
{
int n , tri_num ;
n = 6;
tri_num = n * (n+1) / 2 ;
System.out.println("The value of the triangular number "+n+" is "+tri_num);
}
}
0 comments:
Post a Comment