Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Trial1
- {
- public static void main(String[] args)
- {
- final long startTime = System.currentTimeMillis();
- int count = 0;
- long result = 5;
- for(int x = 5; x < 2_000_000; x++)
- {
- if(x % 2 != 0)
- {
- if(x % 3 != 0)
- {
- for(int y = 5; y <= Math.round(x / 5); y += 2)
- {
- if(x % y == 0)
- {
- count += 1;
- }
- }
- if(count == 0)
- {
- result += x;
- }
- else
- {
- count = 0;
- }
- }
- }
- }
- System.out.println("Result: " + result );
- final long endTime = System.currentTimeMillis();
- final double total = (double)(endTime - startTime) / (double)1000;
- System.out.println("Total execution time: " + total +" seconds");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment