Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // First Version of Ramanujan's Taxi
  2. def ramtaxi(n: Long) = {
  3. for (a <- 1L to n) {
  4. val a3 = a * a * a
  5. if (a3 <= n)
  6. for (b <- a to n) {
  7. val b3 = b * b * b
  8. if (b3 <= n)
  9. for (c <- a + 1 to n) {
  10. val c3 = c * c * c
  11. if (c3 <= n)
  12. for (d <- c to n) {
  13. val d3 = d * d * d
  14. if (d3 <= n && a3 + b3 == c3 + d3) {
  15. println(a3 + b3 + " = " + a + "^3 + "
  16. + b + "^3 = " + c + "^3 + " + d + "^3")
  17. }
  18. }
  19. }
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement