paranid5

4 28.11

Nov 28th, 2021 (edited)
738
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extension on int {
  2.   List<int> getDivs(bool Function(int) predicate) {
  3.     final divs = List<int>.empty(growable: true);
  4.     for (int i = 1; i * i <= this; i++) {
  5.       if (this % i == 0) {
  6.         if (predicate(i)) {
  7.           divs.add(i);
  8.         }
  9.  
  10.         if (i * i < this && predicate(this ~/ i)) {
  11.           divs.add(this ~/ i);
  12.         }
  13.       }
  14.     }
  15.  
  16.     return divs;
  17.   }
  18. }
  19.  
  20. extension on List<int> {
  21.   List<int> sortAndGet() {
  22.     sort();
  23.     return this;
  24.   }
  25. }
  26.  
  27. void main(final List<String> arguments) {
  28.   Iterable
  29.       .generate(190080 - 190061 + 1, (x) => x + 190061)
  30.       .map((e) => e.getDivs((x) => x % 2 == 1))
  31.       .where((element) => element.length == 4)
  32.       .forEach((e) => print(e.sortAndGet()));
  33. }
  34.  
RAW Paste Data