a[0]=0
a[1]=a[2]=1
a[n]=a[n-1]+a[n-2]
利用遞迴公式列出a[n] n=2....40
並比較下列公式
f[2]=1
f[3]=2
f[4]=3
f[5]=5
f[6]=8
f[7]=13
f[8]=21
f[9]=34
f[10]=55
f[11]=89
f[12]=144
f[13]=233
f[14]=377
f[15]=610
f[16]=987
f[17]=1597
f[18]=2584
f[19]=4181
f[20]=6765
f[21]=10946
f[22]=17711
f[23]=28657
f[24]=46368
f[25]=75025
f[26]=121393
f[27]=196418
f[28]=317811
f[29]=514229
f[30]=832040
f[31]=1346269
f[32]=2178309
f[33]=3524578
f[34]=5702887
f[35]=9227465
f[36]=14930352
f[37]=24157817
f[38]=39088169
f[39]=63245986
f[40]=102334155
herrDeng網內搜尋

自訂搜尋
Ads
2011年6月2日 星期四
訂閱:
張貼留言 (Atom)
熱門文章
-
請用Random產生20個0~99的奇數(可重複),然後排序
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
C++ Py3 計數排序與partial sum解Leetcode 2300 Successful Pairs of Spells and Potions Portions的極大值小於等於10萬是可進行記數排序的關鍵,既然可以採用記數排序,後面的二元搜尋也可以透過part...
-
Py3 C++ C 2pointer速解Leetcode 11Container With Most Water [Py3 code請進]
-
Py3 C++計數bitmask與2 pointers速解Leetcode2273 Find Resultant Array After Removing Anagrams 字串長度最長也只有10,四個bits一組,用bitmask解題 ----- The maximum le...
20 則留言:
import java.util.*;
public class cc{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class cc{
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\t"+"a("+i+")="+a(i));
}
}
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class cc{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class abc{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class celtics{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class jjj{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class ggggg{
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class fibonacci3{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return(a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2;i<=n;i++){
f[i]=f[i-1]+f[i-2];
System.out.println("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[]args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1= Math.pow((1+sqrt5)/2,n);
double a2= Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class fibonacci{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class celtics{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main (String[]args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class y1{
public static double a(int n)
{
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2,n);
double a2=Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for(int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class Fibonacci{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1= Math.pow((1+sqrt5)/2,n);
double a2= Math.pow((1-sqrt5)/2,n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int[n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("a("+1+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
import java.util.*;
public class cc{
public static double a(int n){
double sqrt5=Math.sqrt(5);
double a1=Math.pow((1+sqrt5)/2, n);
double a2=Math.pow((1-sqrt5)/2, n);
return (a1-a2)/sqrt5;
}
public static void f(int n){
int f[]=new int [n+1];
f[0]=0;f[1]=1;
for (int i=2; i<=n; i++){
f[i]=f[i-1]+f[i-2];
System.out.print("f["+i+"]="+f[i]);
System.out.println("\ta("+i+")="+a(i));
}
}
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
int n=input.nextInt();
f(n);
}
}
張貼留言