Skip to content

Instantly share code, notes, and snippets.

@olumidayy
Last active May 14, 2020 02:48
Show Gist options
  • Save olumidayy/f319ac0bdfd7b82a7a924449c688bcf6 to your computer and use it in GitHub Desktop.
Save olumidayy/f319ac0bdfd7b82a7a924449c688bcf6 to your computer and use it in GitHub Desktop.
mobile day 13
import 'dart:math';
void main() {
print(Taxi(2));
}
int Taxi(n) {
/* function to find the n-th
* taxicab number*/
List li = [];
var i = 1, j = 2;
while (i < n + 1) {
var l = [
for (int f = 1; f < pow(j, 1 / 3); f++)
for (int s = 1; s < pow(j, 1 / 3); s++)
if (pow(f, 3) + pow(s, 3) == j && f >= s) [f, s]
];
if (l.length == i) {
li.add(j);
i += 1;
}
j += 1;
}
return li[li.length - 1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment