Small update to prime numbers app
Data is now saved to a list to save on system performance. The list is printed out once all of the prime numbers up to the limit have been discovered.
This commit is contained in:
		@@ -13,6 +13,7 @@ namespace Prime_Numbers__Efficient_
 | 
			
		||||
            int startNum = 2;
 | 
			
		||||
            int maxNum = Convert.ToInt32(Console.ReadLine());
 | 
			
		||||
            bool isPrime = true;
 | 
			
		||||
            List<int> primeList = new List<int>();
 | 
			
		||||
 | 
			
		||||
            for (int x = startNum; x <= maxNum; x++)
 | 
			
		||||
            {
 | 
			
		||||
@@ -26,18 +27,20 @@ namespace Prime_Numbers__Efficient_
 | 
			
		||||
                }
 | 
			
		||||
                if (isPrime == true)
 | 
			
		||||
                {
 | 
			
		||||
                    Console.ForegroundColor = ConsoleColor.Green;
 | 
			
		||||
                    Console.WriteLine(x);
 | 
			
		||||
                    primeList.Add(x);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    Console.ForegroundColor = ConsoleColor.Red;
 | 
			
		||||
                    Console.WriteLine(x);
 | 
			
		||||
                    isPrime = true;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var item in primeList)
 | 
			
		||||
            {
 | 
			
		||||
                Console.WriteLine(item);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Console.ReadLine();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user