Last active
April 30, 2020 05:46
-
-
Save sakapon/62e6644f0c0208007325896c03642552 to your computer and use it in GitHub Desktop.
AlgorithmSample / Sample Console App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using AlgorithmLib.Numerics; | |
namespace AlgorithmConsole | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// 素因数分解 | |
Console.WriteLine(string.Join(" * ", Primes.Factorize(2020))); | |
// 2 * 2 * 5 * 101 | |
// 約数の列挙 | |
Console.WriteLine(string.Join(" ", Primes.Divisors(2020))); | |
// 1 2 4 5 10 20 101 202 404 505 1010 2020 | |
// 素数判定 | |
Console.WriteLine(Primes.IsPrime(1000000007)); | |
// True | |
// n 以下の素数の列挙 | |
Console.WriteLine(string.Join(" ", Primes.GetPrimes(100))); | |
// 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 | |
// m 以上 M 以下の素数の列挙 | |
Console.WriteLine(string.Join(" ", Primes.GetPrimes(1000000000, 1000000100))); | |
// 1000000007 1000000009 1000000021 1000000033 1000000087 1000000093 1000000097 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment