fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. // Ideone id = new Ideone();
  14. long t = fact(10);
  15. System.out.println(t);
  16. long y = summery(100);
  17. System.out.println(y);
  18. }
  19. public static long fact(int n){
  20. long res = 1;
  21. for (int i=1; i<=n; i++){
  22. res = res*i;
  23. }
  24. return res;
  25. }
  26.  
  27. public static long summery(int n){
  28. long result = 0;
  29. for (int i=0; i<=n; i++){
  30. if (i % 2 == 0){//парне
  31. result+= i;
  32. }
  33. }
  34. return result;
  35. }
  36.  
  37.  
  38. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
3628800
2550