So I want to do this:

Write a function with two inputs X and Y that can tell you whether the sum
of X^3 and Y^3 is a cube number so long as that sum is under 500 000 000.

This is actually the special case of Fermat's Last Theorem where n=3. We
know that there are no integers X and Y for which X^3 + Y^3 = Z^3 is true,
but I suppose there are decimal numbers and fractions for which it is
true...

My code is as follows:

> my.function <- function(X,Y) {
+ b <- round((X^(3)+Y^(3))^(1/3),digits=6)
+ if (b%%1==0) {return("Cube number")
+ } else {
+ return("Not a cube number")
+ }
+ }

How can I implement the condition that the sum must be under 500 000 000 ?
Does the code look all right?



--
View this message in context: 
http://r.789695.n4.nabble.com/R-Function-with-two-inputs-telling-whether-the-sum-is-a-cube-number-tp4718688.html
Sent from the datatable-help mailing list archive at Nabble.com.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to