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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 階乗計算(1! - 49! 各 64 桁) | |
#********************************************* | |
# | |
class CalcFactorial | |
L = 64 # 計算桁数 | |
L2 = (L + 7 ) / 8 # 配列サイズ | |
N = 49 # 計算個数 |
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 'twitter' | |
require 'oauth' | |
# Consumer key, Secretの設定 | |
CONSUMER_KEY = "XXXXXXXXXXXXXXXXXXXX" | |
CONSUMER_SECRET = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
# Access Token Key, Secretの設定 | |
ACCESS_TOKEN_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
ACCESS_SECRET = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 円周率計算 by Klingenstierna の公式 | |
#********************************************* | |
# | |
class CalcPiKlingenstierna | |
FNAME = "pi_klingenstierna.txt" | |
def initialize(x) | |
@l = x # 計算桁数 |
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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 円周率計算 by オイラーの公式 | |
#********************************************* | |
# | |
class CalcPiEular | |
FNAME = "pi_eular.txt" | |
def initialize(x) | |
@l = x # 計算桁数 |
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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 円周率計算 by Arctan 系の公式 | |
# | |
# 1: Machin | |
# 2: Klingenstierna | |
# 3: Euler | |
# 4: Euler(2) | |
#********************************************* | |
# |
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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 円周率計算 by Arctan 系の公式 | |
# ( 各項の Arctan を個別に計算後に加減算する方法 ) | |
# | |
# 1: Machin | |
# 2: Klingenstierna | |
# 3: Euler | |
# 4: Euler(2) | |
# 5: Gauss |
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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 多桁計算 | |
# ( 符号は考慮しない。) | |
#********************************************* | |
# | |
class CalcBigDigits | |
N_A = 1000 # 計算桁数 ( 被加減乗除数 ) | |
N_B = 996 # 計算桁数 ( 加減乗除数 ) | |
LIMIT = 4 # 配列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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 多倍長乗算 ( by 標準(筆算)方式 ) | |
# - 多倍長 * 多倍長 | |
# - 最下位の桁を配列の先頭とする考え方 | |
#********************************************* | |
# | |
class MultiplyNormal | |
D_MAX = 1024 # 計算可能な最大桁数 ( 2のべき乗 ) | |
D = 1024 # 実際に計算する桁数 ( D_MAX 以下の 4 の倍数 ) |
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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 多倍長乗算 ( by Karatsuba 法 ) | |
# - 多倍長 * 多倍長 | |
# - 最下位の桁を配列の先頭とする考え方 | |
#********************************************* | |
# | |
class MultiplyKaratsuba | |
D_MAX = 1024 # 計算可能な最大桁数 ( 2のべき乗 ) | |
D = 1024 # 実際に計算する桁数 ( D_MAX 以下の 4 の倍数 ) |
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
#! /usr/local/bin/ruby | |
#********************************************* | |
# 多倍長乗算 ( by Toom-Cook 法 (3-way) ) | |
# - 多倍長 * 多倍長 | |
# - 最下位の桁を配列の先頭とする考え方 | |
#********************************************* | |
# | |
class MultiplyToomCook3 | |
D_MAX = 729 # 計算可能な最大桁数 ( 3 のべき乗 ) | |
D = 729 # 実際に計算する桁数 ( D_MAX 以下 ) |