贵金属瓜分(3)青铜分割数浅析
贵金属分割(3)青铜分割数浅析
引自:维基百科
写了个源码:
// febo.cpp : Defines the entry point for the console application. // // sf8.cpp : 定义控制台应用程序的入口点。 //http://blog.****.net/sunboyiris #include "stdafx.h" #include <cstdlib> #include <iostream> #include <time.h> #include <math.h> using namespace std; long qtIter(int n) { if(n==1) return 1; else if(n==2) return 3; else return( 3*qtIter(n-1)+ qtIter(n-2)); } int main() { int N,MAXN=100; long set1,set2; double set; for(int i=1;i<100;i++) { set1=qtIter(i); set2=qtIter(i+1); set=(double(set2))/(double(set1)); cout<<set<<endl; } system("PAUSE"); return EXIT_SUCCESS; }测试结果如下:
原因:采用的也是double型的,所以逼近到3.30278,接近青铜分割数。所写代码无误,至于青铜分割数的用法,欢迎读者来探讨。