灵感来自群星。Ideas from Stellaris
The Ragged Astronauts 衣衫褴褛的宇航员–Bob Shaw
..
计算圆周率pi:
import math
print(math.pi)
//java:
public class PiExample {
public static void main(String[] args) {
double pi = Math.PI;
System.out.println(pi);
}
}
//cpp
#include <iostream>
#include <cmath>
int main() {
double pi = M_PI;
std::cout << pi << std::endl;
return 0;
}
//go
package main
import (
"fmt"
"math"
)
func main() {
pi := math.Pi
fmt.Println(pi)
}
用定义和算法无限精度算:
import decimal
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
def calculate_pi(precision):
decimal.getcontext().prec = precision + 1
C = 426880 * decimal.Decimal(10005).sqrt()
M = 1
X = 1
L = 13591409
S = L
K = 6
for i in range(1, M + 1):
L += 545140134
X *= -262537412640768000
S += decimal.Decimal(L) / (X * decimal.Decimal(K)**3 * factorial(6 * i - 5) * factorial(3 * i - 1) * factorial(i - 1)**3)
K += 12
pi = C / S
return pi
# Calculate pi to 1000 bits (approximately 301 decimal digits)
precision = 1000
pi = calculate_pi(precision)
print(pi)
3.1415926535897342088071648992517339094366415814092695216334519228279645220934824617495589345466065161762422675733824763756611005780957875259350228243618937937932636064196598777396490078630438594759091325774894698735124695168755411107870365528604119304010923102883311329102658365589274953066255766800442427845268635960973661364425287493232538936493209758652372806600644924826626849247995856536361313789984684255969686734080563880080863391156477104428935300831725329769576724019186601486917207191187672724759595881158374602133713911606566143555418146394769803170189746196778572344239084132039726433483227305632572114484277622527273686768076249042504935550500092257951763786313988472749939591660922432392227178571247760101481365965530140240011973852344274603994830602772053282230303828048383643065414806987286423246318179377646381766439242691435409297726779091968886720470492896679485130478759562344751401569584712730372259693866245705552655198157393998778845515515828702098706554032687426196701387773736
未完成:
于命运修改了下,继续更: iStoreOS, Openwrt, Grafana, CaasOS,网关搭建(旁路由)。
java黑马商城项目微服务实战开发(涵盖MybatisPlus、Docker、MQ、ES、Redis高级等)