Advertisement
LEANDRONIEVA

Punto3Tp4PC

Sep 28th, 2023
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Punto3 {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.  
  8.         Random random = new Random();
  9.         int root;
  10.         double inicio = System.currentTimeMillis();
  11.         double fin;
  12.         double tiempo;
  13.         for (int i = 1; i <= 20; i++) {
  14.             root = random.nextInt(1,20);
  15.             System.out.println(SumRootN(root));
  16.         }
  17.         fin = System.currentTimeMillis();
  18.         tiempo = fin-inicio;
  19.         System.out.println("Tiempo transcurrido sin concurrencia: "+tiempo);
  20.        
  21.        
  22.         for (int i = 1; i <= 20; i++) {
  23.             Hilo hilo = new Hilo(i);
  24.            
  25.             hilo.start();
  26.         }
  27.     }
  28.     public static double SumRootN(int root) {
  29.         double result = 0;
  30.         for (int i = 0; i < 10000000; i++) {
  31.             result += Math.exp(Math.log(i) / root);
  32.         }
  33.         return result;
  34.     }
  35.    
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement