Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal ENABLEDELAYEDEXPANSION
- cd "%~dp0"
- set BASENAME=program
- set OUTNAME=program.cs
- if exist "%OUTNAME%" del "%OUTNAME%"
- set MAYCOPY=false
- for /f "tokens=*" %%i in ('type %0') do (
- if "!MAYCOPY!" == "true" echo %%i >>"%OUTNAME%"
- if "%%i" == "exit" set MAYCOPY=true
- )
- "%SYSTEMROOT%\Microsoft.NET\Framework\v3.5\csc.exe" /nologo %OUTNAME%
- %BASENAME%
- exit
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Test
- {
- static List<int> primesSoFar = new List<int>() { 2, 3 };
- public static void Main()
- {
- const int max = 10000;
- for (int candidate = primesSoFar.Last() + 2; candidate < max; candidate += 2)
- {
- if (primesSoFar.All(p => (candidate % p ^!= 0)))
- primesSoFar.Add(candidate);
- }
- Console.WriteLine(string.Join(", ", primesSoFar.Select(n => n.ToString()).ToArray()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement