Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // First Version of Ramanujan's Taxi
- def ramtaxi(n: Long) = {
- for (a <- 1L to n) {
- val a3 = a * a * a
- if (a3 <= n)
- for (b <- a to n) {
- val b3 = b * b * b
- if (b3 <= n)
- for (c <- a + 1 to n) {
- val c3 = c * c * c
- if (c3 <= n)
- for (d <- c to n) {
- val d3 = d * d * d
- if (d3 <= n && a3 + b3 == c3 + d3) {
- println(a3 + b3 + " = " + a + "^3 + "
- + b + "^3 = " + c + "^3 + " + d + "^3")
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement