Last active
May 14, 2020 02:48
-
-
Save olumidayy/f319ac0bdfd7b82a7a924449c688bcf6 to your computer and use it in GitHub Desktop.
mobile day 13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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