Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication14
- {
- class Program
- {
- static void Main(string[] args)
- {
- int primeInQuestion = int.Parse(Console.ReadLine());
- int i = primeInQuestion - 1;
- while (primeInQuestion%i != 0 && i>1 && primeInQuestion != 2 && primeInQuestion !=3)
- {
- i--;
- if (i < 3 && primeInQuestion % i != 0 )
- Console.WriteLine(primeInQuestion + " is prime.");
- }
- if(primeInQuestion == 2 || primeInQuestion == 3)
- Console.WriteLine(primeInQuestion + " is prime.");
- if (i>1 && primeInQuestion%i ==0 && primeInQuestion > 3)
- Console.WriteLine(primeInQuestion + " isn't prime.");
- }
- }
- }
- /* Fibonacci:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication14
- {
- class Program
- {
- static void Main(string[] args)
- {
- int a1 = 0;
- int a2 = 1;
- Console.Write("Amount of numbers you'd like to be calculated: ");
- int amount = int.Parse(Console.ReadLine());
- Console.WriteLine(a1 + "\n" + a2);
- int i = 0;
- while (i < (amount-2))
- {
- i++;
- int a3 = a1 + a2;
- Console.WriteLine(a3);
- a1 = a2;
- a2 = a3;
- }
- }
- }
- }
- */
- /* Triangle:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication14
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter lenght:");
- int lenght = int.Parse(Console.ReadLine());
- int i = 0;
- while (i < lenght)
- {
- i++;
- int b = i;
- while (b > 0)
- {
- b--;
- Console.Write("*");
- }
- Console.WriteLine();
- }
- }
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement