Pythagorean quadruples: Difference between revisions
Content added Content deleted
ReeceGoding (talk | contribs) m (→{{header|R}}: Syntax highlighting.) |
|||
Line 1,725: | Line 1,725: | ||
=={{header|R}}== |
=={{header|R}}== |
||
The best solution to this problem - using lots of for loops - is practically language agnostic. The R way of doing this is far less efficient, taking about 10 minutes on my machine, but it's the obvious way to do this in R. |
The best solution to this problem - using lots of for loops - is practically language agnostic. The R way of doing this is far less efficient, taking about 10 minutes on my machine, but it's the obvious way to do this in R. |
||
<lang |
<lang rsplus>squares <- d <- seq_len(2200)^2 |
||
aAndb <- outer(squares, squares, '+') |
aAndb <- outer(squares, squares, '+') |
||
aAndb <- aAndb[upper.tri(aAndb, diag = TRUE)] |
aAndb <- aAndb[upper.tri(aAndb, diag = TRUE)] |