Fibonacci numbers in Io
            Example for versions 
            
                Io-2008-01-07
            
            
                
                        
	        
        
    
This example uses Binet’s formula. Math functions are called by sending a message to the number which is an object as well.
g := (5 sqrt + 1) / 2;
for(i,1,16,
   N := ((g pow(i)) - ((1-g) pow(i))) / (5 sqrt);
   N round print;
   ", " print;
);
"..." println; 
Comments
]]>blog comments powered by Disqus
]]>