Hello all,
I need a program to print a fibanoci series as follows1,1,2,3,5,8,13,21 with out using a 3rd variable can any one post me please.
Thanks In Advance,
M.Dorababu
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
pandiarajan rajan10 reputationPosted Oct 27, 2009, 9:38 PM EDT
Hi, Make a look at this public static void fibonacci(int n) { int previous = 0; int next = 1; for (int i = 0; i } }Dorababu MekaRank #457 · 5.5K reputationPosted Oct 27, 2009, 8:50 PM EDT
using System;
using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class fab { public static int fibonacci(int n) { int previous = -1; int next = 1; for (int i = 0; i < n; i++) { int sum = next + previous; //previous = next+previous; // previous = previous + next; //next = next-previous; //previous = next - previous; previous = next; next = sum; Console.WriteLine(next); } return next; } static void Main(string[] a) { int num; Console.WriteLine("Enter a number:"); num = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\n"); Console.WriteLine("The first " + num + " number(s) in the fibonacci series are: "); fibonacci(num); Console.Read(); } } }Deepak Bhatia142 reputationPosted Oct 27, 2009, 9:15 PM EDT
You need recursive PROGRAM or a simple program without recursive function.