Fusc sequence: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: terminology) |
ReeceGoding (talk | contribs) (→{{header|R}}: Improved speed and readability of which() calls.) |
||
Line 2,324: | Line 2,324: | ||
A proper solution that only gives one non-trivial result is as follows: |
A proper solution that only gives one non-trivial result is as follows: |
||
<lang r>index<-which(nchar(first61)==2) |
<lang r>index<-which.max(nchar(first61)==2) |
||
number<-first61[index] |
number<-first61[index] |
||
cat("The first fusc number that is longer than all previous fusc numbers is",number, |
cat("The first fusc number that is longer than all previous fusc numbers is",number, |
||
Line 2,331: | Line 2,331: | ||
<lang r>twentyMillion<-firstNPlus1FuscNumbers(2*10^7-1) |
<lang r>twentyMillion<-firstNPlus1FuscNumbers(2*10^7-1) |
||
twentyMillionCountable<-format(twentyMillion,scientific = FALSE,trim = TRUE) |
twentyMillionCountable<-format(twentyMillion,scientific = FALSE,trim = TRUE) |
||
indices<-sapply(2:6, function(x) |
indices<-sapply(2:6, function(x) which.max(nchar(twentyMillionCountable)==x)) |
||
numbers<-twentyMillion[indices] |
numbers<-twentyMillion[indices] |
||
cat("Some fusc numbers that are longer than all previous fusc numbers are:\n", |
cat("Some fusc numbers that are longer than all previous fusc numbers are:\n", |