cardel

EjemploMDIIGO14Dic

Dec 14th, 2020
1,258
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import "fmt"
  4. import "math"
  5.  
  6. func recursivo(n int) float64{
  7.  
  8.   if n == 0{
  9.     return 4.0
  10.   }else{
  11.     if n == 1{
  12.       return 8.0
  13.     }else{
  14.       return 7.0*recursivo(n-1)+3.0*recursivo(n-2)
  15.     }
  16.   }
  17. }
  18.  
  19. func formula(n int) float64{
  20.   var A float64 = -6.0/math.Sqrt(61.0)+2.0
  21.   var B float64 = 6.0/math.Sqrt(61.0)+2.0
  22.   var r1 float64 =math.Pow((7.0+math.Sqrt(61.0))/2.0,float64(n))
  23.   var r2 float64 =math.Pow( (7.0-math.Sqrt(61.0))/2.0,float64(n))
  24.  
  25.   return A*r1+B*r2
  26.  
  27. }
  28.  
  29. func main() {
  30.   for i := 0; i<20; i++{
  31.     fmt.Println("n ",i," recursivo ",recursivo(i)," formula ",formula(i))
  32.   }
  33.  
  34. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×