Expand|Select|Wrap|Line Numbers
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- namespace FindFactors
- {
- class Program
- {
- static void Main(string[] args)
- {
- ThreadWork threadwork = new ThreadWork();
- Console.Write("Enter a number to find the factors of: ");
- string max = Convert.ToString(Console.Read());
- Thread countOdd = new Thread(new ThreadStart(threadwork.countOdd(max)));
- Thread countEven = new Thread(new ThreadStart(threadwork.countEven(max)));
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace FindFactors
- {
- class ThreadWork
- {
- public void countOdd(string max)
- {
- long i = 0;
- long n = Convert.ToInt64(max);
- for (i = 1; i <= n; i += 2)
- {
- if ((n % i) == 0)
- {
- Console.WriteLine(i);
- }
- }
- }
- public void countEven(string max)
- {
- long j = 0;
- long o = Convert.ToInt64(max);
- for (j = 2; j <= o; j+=2)
- {
- if ((o % j) == 0)
- {
- Console.WriteLine(j);
- }
- }
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- Thread countOdd = new Thread(new ThreadStart(threadwork.countOdd(max)));
- Thread countEven = new Thread(new ThreadStart(threadwork.countEven(max)));