Recent Posts

Pages: [1] 2 3 ... 10
1
Code Challenges / Re: fibonacci(4784969)
« Last post by John on Today at 09:52:04 AM »
GMP is the only way to fly.
2
Code Challenges / Re: fibonacci(4784969)
« Last post by AIR on Today at 08:58:29 AM »
Printing is always expensive....



real    0m1.895s
user    0m1.817s
sys     0m0.050s

3
Code Challenges / Re: fibonacci(4784969)
« Last post by jalih on Today at 08:47:31 AM »
RPI 3B+

Very good time! How long does it take to output the whole result?
4
Code Challenges / Re: fibonacci(4784969)
« Last post by AIR on Today at 08:40:18 AM »
riveraa@dpi:~/Projects/Python/gmp $ time ./fibogmp.py
1000000


real    0m0.362s
user    0m0.362s
sys     0m0.000s

Is this on PC or RPI 3 B+ ?


RPI 3B+


riveraa@dpi: ~/Projects/Python/gmp $ uname -a
Linux dpi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux


AIR.


5
Code Challenges / Re: fibonacci(4784969)
« Last post by jalih on Today at 08:29:07 AM »
riveraa@dpi:~/Projects/Python/gmp $ time ./fibogmp.py
1000000


real    0m0.362s
user    0m0.362s
sys     0m0.000s

Is this on PC or RPI 3 B+ ?
6
Code Challenges / Re: fibonacci(4784969)
« Last post by AIR on Today at 08:12:11 AM »
ScriptBasic 1 mil fibo challenge.

Code: Script BASIC
  1. DECLARE SUB fibo ALIAS "fibo" LIB "gmp"
  2.  
  3. PRINT LEN(fibo(4784969)),"\n"
  4.  


pi@RPi3Bplus:~/sbrpi/examples $ time scriba fibogmp.sb
1000000

real   0m1.652s
user   0m1.639s
sys   0m0.010s
pi@RPi3Bplus:~/sbrpi/examples $


Can any other scripting language top this on the RPi 3 B+?


Code: Python
  1. #!/usr/bin/env python
  2.  
  3.  
  4. from gmpy2 import fib
  5.  
  6.  
  7. print fib(4784969).num_digits()
  8.  




riveraa@dpi:~/Projects/Python/gmp $ time ./fibogmp.py
1000000


real    0m0.362s
user    0m0.362s
sys     0m0.000s




AIR.
7
Code Challenges / Re: fibonacci(4784969)
« Last post by jalih on Today at 12:45:28 AM »
Can any other scripting language top this on the RPi 3 B+?

Can you test 8th version I posted earlier on RPi 3 B+ ? I think 3 B+ should be about 15 percent faster than 3 B.
8
Code Challenges / Re: fibonacci(4784969)
« Last post by John on Today at 12:32:18 AM »
ScriptBasic 1 mil fibo challenge.

Code: Script BASIC
  1. DECLARE SUB fibo ALIAS "fibo" LIB "gmp"
  2.  
  3. PRINT LEN(fibo(4784969)),"\n"
  4.  


pi@RPi3Bplus:~/sbrpi/examples $ time scriba fibogmp.sb
1000000

real   0m1.652s
user   0m1.639s
sys   0m0.010s
pi@RPi3Bplus:~/sbrpi/examples $


Can any other scripting language top this on the RPi 3 B+?
9
Code Challenges / Re: fibonacci(4784969)
« Last post by AIR on April 21, 2019, 05:59:47 PM »
Here is an interative GO implementation:
Code: Go
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "math/big"
  6. )
  7.  
  8. func Mul(x, y *big.Int) *big.Int {
  9.     return big.NewInt(0).Mul(x, y)
  10. }
  11.  
  12. func Add(x, y *big.Int) *big.Int {
  13.     return big.NewInt(0).Add(x, y)
  14. }
  15.  
  16. func fib(n int) *big.Int {
  17.     v1, v2, v3 := big.NewInt(1), big.NewInt(1), big.NewInt(0)
  18.     s := fmt.Sprintf("%b", n)
  19.     for i := 1; i < len(s); i++ {
  20.         calc := Mul(v2, v2)
  21.         v1, v2, v3 = Add(Mul(v1, v1), calc), Mul(Add(v1, v3), v2), Add(Mul(v3, v3), calc)
  22.         if s[i] == 49 {
  23.             v1, v2, v3 = Add(v1, v2), v1, v2
  24.         }
  25.     }
  26.     return v2
  27. }
  28. func main() {
  29.  
  30.     result := fib(4784969)
  31.     fmt.Println(result)
  32. }

real    0m2.093s
user    0m2.074s
sys     0m0.018s


AIR.
10
Code Challenges / Re: fibonacci(4784969)
« Last post by AIR on April 21, 2019, 11:11:06 AM »
Without printing the result

real    0m0.352s
user    0m0.342s
sys    0m0.013s


With print

real    0m2.632s
user    0m2.597s
sys    0m0.021s


Test System:

system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: Mac mini
      Model Identifier: Macmini6,2
      Processor Name: Intel Core i7
      Processor Speed: 2.3 GHz
      Number of Processors: 1
      Total Number of Cores: 4
      L2 Cache (per Core): 256 KB
      L3 Cache: 6 MB
      Memory: 16 GB
Pages: [1] 2 3 ... 10