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
require 'prime' | |
# 無限降下法 (descent) | |
# | |
# input: (x, y, k, p) s.t. kp = x^2 + x^2 | |
# output: (x, y, k, p) s.t. p = x^2 + x^2, k = 1 | |
def descent(x, y, k, p) | |
if k == 1 |
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
# 無限降下法 (descent) | |
# | |
# input: (x, y, k, p) s.t. kp = x^2 + x^2 | |
# output: (x, y, k, p) s.t. p = x^2 + x^2, k = 1 | |
def descent(x, y, k, p) | |
if k == 1 | |
return [x, y, 1, p] | |
else |
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
# The Gaussian periods modulo 65537 | |
p = 65537 | |
g = 3 (primitive root modulo 65537) | |
Z/pZ := [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 46073, 7145, 21435, 64305, 61841, 54449, 32273, 31282, 28309, 19390, 58170, 43436, 64771, 63239, 58643, 44855, 3491, 10473, 31419, 28720, 20623, 61869, 54533, 32525, 32038, 30577, 26194, 13045, 39135, 51868, 24530, 8053, 24159, 6940, 20820, 62460, 56306, 37844, 47995, 12911, 38733, 50662, 20912, 62736, 57134, 40328, 55447, 35267, 40264, 55255, 34691, 38536, 50071, 19139, 57417, 41177, 57994, 42908, 63187, 58487, 44387, 2087, 6261, 18783, 56349, 37973, 48382, 14072, 42216, 61111, 52259, 25703, 11572, 34716, 38611, 50296, 19814, 59442, 47252, 10682, 32046, 30601, 26266, 13261, 39783, 53812, 30362, 25549, 11110, 33330, 34453, 37822, 47929, 12713, 38139, 48880, 15566, 46698, 9020, 27060, 15643, 46929, 9713, 29139, 21880, 103, 309, 927, 2781, 8343, 25029, 9550, 28650, 20413, 61239, 52643, 26855, 15028, 45084, 4178, 12534, 37602, 47269, 10733, 32199, 31060, 27643, 17392, 5 |
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
# coding: utf-8 | |
# ガウス周期の大きさ(複素数)を数値的に計算して,正負の判定を行う | |
require 'set' | |
require 'prime' | |
require 'complex' | |
# 原始根を計算する | |
# prime |
This file has been truncated, but you can view the full file.
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
# The Gaussian periods modulo 65537 | |
p = 65537 | |
g = 3 (primitive root modulo 65537) | |
# 1 dim'l Gaussian periods: | |
(65536, 1) = [1]+[3]+[9]+[27]+[81]+[243]+[729]+[2187]+[6561]+[19683]+[59049]+[46073]+[7145]+[21435]+[64305]+[61841]+[54449]+[32273]+[31282]+[28309]+[19390]+[58170]+[43436]+[64771]+[63239]+[58643]+[44855]+[3491]+[10473]+[31419]+[28720]+[20623]+[61869]+[54533]+[32525]+[32038]+[30577]+[26194]+[13045]+[39135]+[51868]+[24530]+[8053]+[24159]+[6940]+[20820]+[62460]+[56306]+[37844]+[47995]+[12911]+[38733]+[50662]+[20912]+[62736]+[57134]+[40328]+[55447]+[35267]+[40264]+[55255]+[34691]+[38536]+[50071]+[19139]+[57417]+[41177]+[57994]+[42908]+[63187]+[58487]+[44387]+[2087]+[6261]+[18783]+[56349]+[37973]+[48382]+[14072]+[42216]+[61111]+[52259]+[25703]+[11572]+[34716]+[38611]+[50296]+[19814]+[59442]+[47252]+[10682]+[32046]+[30601]+[26266]+[13261]+[39783]+[53812]+[30362]+[25549]+[11110]+[33330]+[34453]+[37822]+[47929]+[12713]+[38139]+[48880]+[15566]+[46698]+[9020]+[27060]+[15643]+[46929]+[9713]+[29139]+[21880]+[10 |
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
# The Gaussian periods modulo 257 | |
p = 257 | |
g = 3 (primitive root modulo 257) | |
# 1 dim'l Gaussian periods: | |
(256, 1) = [1]+[3]+[9]+[27]+[81]+[243]+[215]+[131]+[136]+[151]+[196]+[74]+[222]+[152]+[199]+[83]+[249]+[233]+[185]+[41]+[123]+[112]+[79]+[237]+[197]+[77]+[231]+[179]+[23]+[69]+[207]+[107]+[64]+[192]+[62]+[186]+[44]+[132]+[139]+[160]+[223]+[155]+[208]+[110]+[73]+[219]+[143]+[172]+[2]+[6]+[18]+[54]+[162]+[229]+[173]+[5]+[15]+[45]+[135]+[148]+[187]+[47]+[141]+[166]+[241]+[209]+[113]+[82]+[246]+[224]+[158]+[217]+[137]+[154]+[205]+[101]+[46]+[138]+[157]+[214]+[128]+[127]+[124]+[115]+[88]+[7]+[21]+[63]+[189]+[53]+[159]+[220]+[146]+[181]+[29]+[87]+[4]+[12]+[36]+[108]+[67]+[201]+[89]+[10]+[30]+[90]+[13]+[39]+[117]+[94]+[25]+[75]+[225]+[161]+[226]+[164]+[235]+[191]+[59]+[177]+[17]+[51]+[153]+[202]+[92]+[19]+[57]+[171]+[256]+[254]+[248]+[230]+[176]+[14]+[42]+[126]+[121]+[106]+[61]+[183]+[35]+[105]+[58]+[174]+[8]+[24]+[72]+[216]+[134]+[145]+[178]+[20]+[60]+[180]+[26]+[78]+[234]+[188]+[50]+[150]+[193]+[65]+[195]+[71] |
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
module Dijkstra | |
# ノード全体を格納するクラス | |
class Nodes | |
def initialize | |
@done = false | |
@map = {} | |
end |
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
# coding: utf-8 | |
require 'prime' | |
# Legendre symbol | |
def legendre(a, p) | |
p.times do |x| | |
if (x*x - a) % p == 0 then | |
return 1 |
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
# zeta.rb | |
require 'complex' | |
LOWER_THRESHOLD = 1.0e-6 | |
UPPER_BOUND = 1.0e+4 | |
MAXNUM = 100 | |
module Zeta |
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
def jonessatowadawiens(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) | |
res=(k+2)*(1-(w*z+h+j-q)**2 \ | |
-((g*k+2*g+k+1)*(h+j)+h-z)**2 \ | |
-(2*n+p+q+z-e)**2 \ | |
-(16*((k+1)**3)*(k+2)*((n+1)**2)+1-f**2)**2 \ | |
-((e**3)*(e+2)*((a+1)**2)+1-o**2)**2 \ | |
-((a**2-1)*(y**2)+1-x**2)**2 \ | |
-(16*(r**2)*(y**4)*(a**2-1)+1-u**2)**2 \ | |
-(( (a+(u**2)*(u**2-a))**2 -1)*(n+4*d*y)**2 + 1-(x+c*u)**2)**2 \ |