Examples of Java data structures and algorithms: trigonometric Numbers

  • 2020-04-01 03:56:55
  • OfStack


 
package al; 
public class Triangle { 
  public static void main(String[] args) { 
    Triangle triangle = new Triangle(); 
    int result = triangle.getValue(100); 
    System.out.println("Result is " + result); 
  } 
   
  public int getValue (int n) { 
    if (n == 1) { 
      return 1; 
    } else { 
      return n + getValue(n - 1); 
    } 
  } 
} 



Related articles: