| Author |
Comment/Response |
Peter Pein
|
10/27/08 07:00am
Hi,
please do not use N as variable. It is a kernel-function.
NestWhileList is the 'natural' way to do this:
n0 = (1/2)*(3 + Sqrt[5]);
f[e_] := Length[NestWhileList[Sqrt[#1] + 1 & , 2., Abs[n0 - #1] >= e & ]] - 1
for example: f /@ (10^Range[-8, 0])
gives
{16, 14, 12, 10, 8, 6, 4, 2, 0}
URL: , |
|