Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Primes
- {
- static double getM(Int64 varNInGetM){
- Double m = Math.Sqrt(Double.Parse(varNInGetM.ToString()));
- m = Math.Round(m, 0, MidpointRounding.AwayFromZero);
- m++;
- return m;
- }
- static List<Int64> Get_Numbers(Int64 varNInGetNum){
- List<Int64> numbers = new List<Int64>();
- numbers.Add(2);
- Console.Clear();
- for (Int64 i = 3; i < varNInGetNum; i += 2){
- numbers.Add(i);
- }
- return numbers;
- }
- static Int64[] get_amount(Int64 varNInGetAmt){
- Int64[] amount = new Int64[varNInGetAmt];
- for (Int64 i = 0; i < varNInGetAmt; i++){
- amount[i] = 0;
- }
- return amount;
- }
- static void cnslFunc(){
- Console.Clear();
- Console.SetCursorPosition(0, 0);
- }
- public List<Int64> CalcPrimes(Int64 n){
- List<Int64> numbers = Get_Numbers(n); Double m = getM(n);
- for (Int64 i = 3; i <= m; i+=2){
- if (numbers.Contains(i)){
- numbers.RemoveAll(x => x % i == 0 && x != i);
- }
- }
- return numbers;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement