Wednesday, July 6, 2011

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);
}
}

No comments:

Post a Comment