Bruger:NivlekDa/FiboKodestykker: Forskelle mellem versioner

Content deleted Content added
m flyttede Bruger:Nivlek/FiboKodestykker til Bruger:NivlekDa/FiboKodestykker: Automatisk flyttet side under omnavngivning af bruger "Nivlek" til "NivlekDa"
Xqbot (diskussion | bidrag)
m Bot: Replace deprecated <source> tag and "enclose" parameter; kosmetiske ændringer
 
Linje 2:
 
== [[C++]] program til udskrift af talfølgen ==
<sourcesyntaxhighlight lang="c">
#include <iostream>
 
Linje 22:
return 0;
}
</syntaxhighlight>
</source>
****** C++ program til at regne fibonacci's tal ud ***********************************
<sourcesyntaxhighlight lang="c">
#include <iostream>
using namespace std;
Linje 48:
}
}
</syntaxhighlight>
</source>
 
== [[Perl]]script til udskrift af talfølgen ==
 
<sourcesyntaxhighlight lang="perl">
#!/usr/bin/perl
 
Linje 62:
($a, $b) = ($b, $a+$b);
}
</syntaxhighlight>
</source>
 
== [[Javascript]] script til udskrift af talfølgen ==
<sourcesyntaxhighlight lang="java">
<script type="text/javascript">
var limit = 30;
Linje 78:
}
</script>
</syntaxhighlight>
</source>
== [[PHP]] funktion til udskrift af talfølgen ==
<sourcesyntaxhighlight lang="php">
<?php
function Fibonacci($num)
Linje 97:
Fibonacci(10);
?>
</syntaxhighlight>
</source>
 
 
== [[PHP]] funktion til udskrift af talfølgen vha. rekursion ==
<sourcesyntaxhighlight lang="php">
<?php
function fibonacci($num){
Linje 119:
echo Fibonacci($input);
?>
</syntaxhighlight>
</source>
 
== [[Active Server Pages|ASP]] funktion til udskrift af talfølgen ==
<sourcesyntaxhighlight lang="asp">
<%
function Fibonacci(counter)
Linje 141:
Fibonacci(10)
%>
</syntaxhighlight>
</source>
 
== [[Python (programmeringssprog)|Python]] program til udskrift af talfølgen ==
<sourcesyntaxhighlight lang="python">
a, b = 0, 1
while b < 20000:
print b,
a, b = b, a+b
</syntaxhighlight>
</source>
 
Program til udregning af et bestemt nummer i talfølgen
<sourcesyntaxhighlight lang="python">
 
 
Linje 173:
if(count == maxcount):
print ("Dit nummer blev: ", number)
</syntaxhighlight>
</source>
 
== [[Scala (programmeringssprog)|Scala]] funktion til udskrift af talfølgen ==
<sourcesyntaxhighlight lang="scala">
def f(n : Int) : Int = n match {
case 0 => 0;
Linje 182:
case n => f(n - 1) + f(n - 2)
}
</syntaxhighlight>
</source>
 
 
== [[F Sharp|F#]] funktion til udskrift af talfølgen ==
<sourcesyntaxhighlight lang="ocaml">
let printFibs amount =
let rec currentFib a b i =
Linje 193:
currentFib (a + b) a (i + 1)
currentFib 1L 0L 0
</syntaxhighlight>
</source>