[R] Fibonacci

From: Georgina Imberger <gimberger_at_gmail.com>
Date: Wed, 20 Apr 2011 11:42:38 +0200


Hi!

I am trying to work out the code to get a Fibonacci sequence, using the while() loop and only one variable. And I can't figure it out.

Fibonacci<-c(1,1)
while (max(Fibonacci)<500){
Fibonacci<-c(Fibonacci, (max(Fibonacci) + ?(Fibanacci))) }

How can I tell R to take the value one before the max value? (Without defining another variable)

(Probably super easy... I am a beginner...)

Thanks,
Georgie

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 20 Apr 2011 - 10:36:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Apr 2011 - 13:40:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive