fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static int largestTriangleNumberSmallerThan(int x) {
  7. int n = (int) (Math.sqrt(8*x + 1) - 1)/2;
  8. return n*(n+1)/2;
  9. }
  10.  
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. System.out.println(largestTriangleNumberSmallerThan(65));
  14. }
  15. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
55