1. Fibonacci Series: The Fibonacci series is a sequence of numbers in which each is the sum of the two preceding ones, usually starting with 0 and 1. The arrangement goes like 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... and so on. Example Program: |
using System; public class Fibonacci { static void Main(string[ ] args) { int a = 0, b = 1, c; Console.WriteLine("Enter How many Fibanacci Numbers you want to print: "); int number = int.Parse(Console.ReadLine()); Console.WriteLine(a + "\n" + b); for (int i = 0; i < number; i++) { c = a + b; Console.WriteLine(c); a = b; b = c; } } } |
2. Palindrome Number: A palindrome is a word, phrase, number, or other sequences of characters that reads the same backward or forward. Examples include "madam", "racecar" and "56765". Example Program: |
using System; class Palindromenumber { static void Main(string[] args) { Console.WriteLine("Enter a number to check if it is Palindrome number or not"); int number=int.Parse(Console.ReadLine()); int r,sum=0,temp; temp=number; while(number>0) { r=number%10; sum=(sum*10)+r; number=number/10; } if(temp.Equals(sum)) Console.WriteLine( "Entered number is a palindrome number"); else Console.WriteLine(" Entered number is not a palindrome number"); } } |
No comments:
Post a Comment