[{{mminutes}}:{{sseconds}}] X
Пользователь приглашает вас присоединиться к открытой игре игре с друзьями .
Project Euler Java Solutions
(1)       Используют 6 человек

Комментарии

Ни одного комментария.
Написать тут
Описание:
Solutions to the Euler Project problems, written in Java.
Автор:
Nes370
Создан:
5 октября 2019 в 02:52 (текущая версия от 5 октября 2019 в 10:33)
Публичный:
Да
Тип словаря:
Тексты
Цельные тексты, разделяемые пустой строкой (единственный текст на словарь также допускается).
Информация:
As || is an invalid character, OR is used instead.
As / is an invalid character, DIV is used instead.
Содержание:
1 public static int problem1() { int sum = 0; for(int i = 1; i < 1000; i++) if(i % 3 == 0 OR i % 5 == 0) sum += i; return sum; }
2 public static int problem2() { int a = 1, b = 2, c = 0, sum = 2; while(b < 4000000) { c = a + b; if(c % 2 == 0) sum += a + b; a = b; b = c; } return sum; }
3 public static long problem3() { long n = 600851475143L; for(long i = 2; i < n; i++) if(n % i == 0) n DIV= i--; return n; }
4 public static int problem4() { String str = "", revStr = ""; int biggest = 0; for(int i = 999; i > 99; i--) for(int j = 999; j > 99; j--) if(i * j > biggest) { str = (i * j) + ""; revStr = ""; for(int k = str.length() - 1; k >= 0 ; k--) revStr += str.charAt(k); if(str.equals(revStr)) biggest = i * j; } return biggest; }
5 public static long problem5() { long n = 1; for(int i = 1; i <= 20; i++) { if(n DIV i == 0 OR n % i != 0) { long a = n; long b = i; while(b != 0) { if(a > b) { long c = a; a = b; b = c % b; } else b %= a; } n = n DIV a * i; } } return n; }
6 public static long problem6() { long sum = 0, square = 0; for(int i = 1; i < 101; i++) { sum += i * i; square += i; } return square * square - sum; }
7 public static long problem7() { long value = 3; boolean prime; for(int n = 1; n < 10001; value++) { prime = true; int max = (int) Math.sqrt(value) + 1; for(int i = 2; i < max; i++) { if(value % i == 0) { prime = false; break; } } if(prime) n++; } return value - 1; }
8 public static long problem8(String number) { long greatest = 0; for(int i = 0; i < number.length() - 14; i++) { long product = 1; for(int j = 0; j < 13; j++) product *= Integer.parseInt("" + number.charAt(i + j)); if(product > greatest) greatest = product; } return greatest; }
9 public static long problem9() { for(int a = 1; a < 995; a++) for(int b = a + 1; b < 996; b++) for(int c = b + 1; c < 997; c++) if(a + b + c == 1000 && a * a + b * b == c * c) return a * b * c; else if(a + b + c > 1000) break; return 0; }
10 public static long problem10() { long sum = 2; boolean prime; for(int n = 3; n < 2000000; n++) { prime = true; int max = (int) Math.sqrt(n) + 1; for(int i = 2; i < max; i++) { if(n % i == 0) { prime = false; break; } } if(prime) sum += n; } return sum; }

Связаться
Выделить
Выделите фрагменты страницы, относящиеся к вашему сообщению
Скрыть сведения
Скрыть всю личную информацию
Отмена