Print first n Fibonacci Numbers using direct formula | C # code to print fibonacci numbers till n using direct formula . \ ; Function to calculate fibonacci using recurrence relation formula ; Using direct formula ; Driver code
using System ; public class GFG { static void fibonacci ( double n ) { double fib ; for ( double i = 0 ; i < n ; i ++ ) { fib = ( Math . Pow ( ( 1 + Math . Sqrt ( 5 ) ) , i ) - Math . Pow ( ( 1 - Math . Sqrt ( 5 ) ) , i ) ) / ( Math . Pow ( 2 , i ) * Math . Sqrt ( 5 ) ) ; Console . Write ( ( int ) fib + " ▁ " ) ; } } static public void Main ( ) { double n = 8 ; fibonacci ( n ) ; } }