Fibonacci word: Difference between revisions

Line 3,298:
37 24157817 0.9594187282227448
</pre>
 
=={{header|Scilab}}==
===Recursive approach===
It uses Scilab's [[Entropy#Scilab|entropy]] example.
<lang>exec('.\entropy.sci',0);
 
function word=fiboword(n)
word_1 = '1'; word_2 = '0';
select n
case 1
word = word_1
case 2
word = word_2;
case 3
word = strcat([word_2 word_1]);
else
word = strcat([fiboword(n-1) fiboword(n-2)])
end
endfunction
 
N=37;
char_length = zeros(N,1);
entropies = zeros(N,1);
tic();
for i=1:N
word = fiboword(i);
char_length(i) = length(word);
entropies(i) = entropy(word);
end
time = toc();
 
disp('EXECUTION TIME: '+string(time)+'s.');
disp(['N', 'LENGTH', 'ENTROPY'; string([[1:N]' char_length entropies])]);</lang>
 
{{out}}
<pre> EXECUTION TIME: 442.87612s.
 
!N LENGTH ENTROPY !
! !
!1 1 0 !
! !
!2 1 0 !
! !
!3 2 1 !
! !
!4 3 0.9182958 !
! !
!5 5 0.9709506 !
! !
!6 8 0.954434 !
! !
!7 13 0.9612366 !
! !
!8 21 0.9587119 !
! !
!9 34 0.9596869 !
! !
!10 55 0.9593160 !
! !
!11 89 0.9594579 !
! !
!12 144 0.9594038 !
! !
!13 233 0.9594244 !
! !
!14 377 0.9594165 !
! !
!15 610 0.9594196 !
! !
!16 987 0.9594184 !
! !
!17 1597 0.9594188 !
! !
!18 2584 0.9594187 !
! !
!19 4181 0.9594187 !
! !
!20 6765 0.9594187 !
! !
!21 10946 0.9594187 !
! !
!22 17711 0.9594187 !
! !
!23 28657 0.9594187 !
! !
!24 46368 0.9594187 !
! !
!25 75025 0.9594187 !
! !
!26 121393 0.9594187 !
! !
!27 196418 0.9594187 !
! !
!28 317811 0.9594187 !
! !
!29 514229 0.9594187 !
! !
!30 832040 0.9594187 !
! !
!31 1346269 0.9594187 !
! !
!32 2178309 0.9594187 !
! !
!33 3524578 0.9594187 !
! !
!34 5702887 0.9594187 !
! !
!35 9227465 0.9594187 !
! !
!36 14930352 0.9594187 !
! !
!37 24157817 0.9594187 !</pre>
 
=={{header|Seed7}}==