Advertisement
AvengersAssemble

Untitled

Sep 3rd, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication12
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             for (int cicles = 0; cicles >= 0; cicles++)
  14.             {
  15.                 Console.WriteLine("Press 1 for Fibonacci \nPress 2 for multiplication table\nPress 3 for 5 digits number revesor \nPress 4 for prime number checker");
  16.                 int actionNum = int.Parse(Console.ReadLine());
  17.                 if (actionNum == 1)
  18.                 {
  19.                     Console.Write("Insert amount of numbers you'd like the program to calculate: ");
  20.                     int fiboNum = int.Parse(Console.ReadLine());
  21.                     Console.WriteLine("0\n1");
  22.                     double a1 = 0;
  23.                     double a2 = 1;
  24.                     for (int i = 0; i < (fiboNum - 2); i++)
  25.                     {
  26.                         double a3 = a1 + a2;
  27.                         Console.WriteLine(a3);
  28.                         a1 = a2;
  29.                         a2 = a3;
  30.                     }
  31.                     Console.WriteLine();
  32.                 }
  33.                 if (actionNum == 2)
  34.                 {
  35.                     for (int a = 1; a <= 10; a++)
  36.                     {
  37.                         for (int b = 1; b <= 10; b++)
  38.                             Console.Write(a * b +" ");
  39.                         Console.WriteLine();
  40.                     }
  41.                     Console.WriteLine();
  42.                 }
  43.                 if (actionNum == 3)
  44.                 {
  45.                     Console.Write("Please insert a 5-digits number: ");
  46.                     int numTBR = int.Parse(Console.ReadLine());
  47.                     int dig1 = numTBR % 10;
  48.                     int dig2 = (numTBR / 10) % 10;
  49.                     int dig3 = (numTBR / 100) % 10;
  50.                     int dig4 = (numTBR / 1000) % 10;
  51.                     int dig5 = (numTBR / 10000) % 10;
  52.                         Console.WriteLine("Reversed number is " + dig1 + "" + dig2 + "" + dig3 + "" + dig4 + "" + dig5 +"\n");
  53.                 }
  54.                 if (actionNum == 4) //prime number checker
  55.                 {
  56.                     Console.Write("Insert number (an integer that is greater than 1): ");
  57.                     int primeInQuestion = int.Parse(Console.ReadLine());
  58.                     int div = 0;
  59.                     int antiMultiMessage = 0;
  60.                     for (int i = primeInQuestion; i > 1; i--)
  61.                     {
  62.                         if (i != primeInQuestion && primeInQuestion % i == 0 && primeInQuestion!=2 && antiMultiMessage == 0)
  63.                         {
  64.                             Console.WriteLine(primeInQuestion + " is not a prime.");
  65.                             div = i;
  66.                             antiMultiMessage = 1;
  67.                             //Console.WriteLine(i);
  68.                         }
  69.                         if (div==0 && i<3 && primeInQuestion%3!=0 && primeInQuestion%2!=0)
  70.                             Console.WriteLine(primeInQuestion + " is a prime number.");
  71.                     }
  72.                     if (primeInQuestion == 2 || primeInQuestion== 3)
  73.                         Console.WriteLine(primeInQuestion + " is a prime number.");
  74.                     Console.WriteLine();
  75.                 }
  76.             }
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement