Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.91 KB | None | 0 0
  1. @echo off
  2. setlocal ENABLEDELAYEDEXPANSION
  3. cd "%~dp0"
  4. set BASENAME=program
  5. set OUTNAME=program.cs
  6. if exist "%OUTNAME%" del "%OUTNAME%"
  7. set MAYCOPY=false
  8. for /f "tokens=*" %%i in ('type %0') do (
  9.   if "!MAYCOPY!" == "true" echo %%i >>"%OUTNAME%"
  10.   if "%%i" == "exit" set MAYCOPY=true
  11. )
  12.  
  13. "%SYSTEMROOT%\Microsoft.NET\Framework\v3.5\csc.exe" /nologo %OUTNAME%
  14. %BASENAME%
  15.  
  16. exit
  17.  
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21.  
  22. public class Test
  23. {
  24.     static List<int> primesSoFar = new List<int>() { 2, 3 };
  25.     public static void Main()
  26.     {
  27.         const int max = 10000;
  28.         for (int candidate = primesSoFar.Last() + 2; candidate < max; candidate += 2)
  29.         {
  30.             if (primesSoFar.All(p => (candidate % p ^!= 0)))
  31.                 primesSoFar.Add(candidate);
  32.         }
  33.         Console.WriteLine(string.Join(", ", primesSoFar.Select(n => n.ToString()).ToArray()));
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement