Varanasi-Software-Junction / CSharp-Basics

MIT License
0 stars 2 forks source link

For loops, while loops #4

Open kittuy opened 1 year ago

kittuy commented 1 year ago

1,2,3,4,5,6,7,8,9,10 2,4,6,8,10 1,3,5,7,9 1,4,9,16,,,,81,100 2,6,12,20,,,,90 1/1,1/2,1/3,1/4, 1/10 Print the Fibonacci Sequence Print the Fibonacci Sequence in reverse Print the table of a given number Change a given number to its reverse form. 123 will become 321

kittuy commented 1 year ago

using System; using System.Collections.Generic; using System.Linq; using System.Text;

namespace @if.condition { class Program { static void Main(string[] args) { int a = 0, b = 1; Console.Write(a + "," + b); int n=10; for (int i = 3; i <= n; i++) { int c = a + b; a = b; b = c; Console.Write("," + c); }

        Console.ReadKey();
    }
} 

}

kittuy commented 1 year ago

Fibonacci Series image 0,1,1,2,3,5,8,13,21,34 34,21,13,8,5,3,2,1,1,0

kittuy commented 1 year ago

Reverse Fibonacci

using System; using System.Collections.Generic; using System.Linq; using System.Text;

namespace basics { class Program { static void Main(string[] args) { int c = 34, b = 21; int a = c - b; Console.Write(c + "," + b); while (a > 0) { Console.Write( "," + a); c = b; b = a; a = c - b; } Console.Write("," + a); Console.ReadKey();

    }
}

}