This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Newbie programmer | |
$input=<>; | |
sub factorial { | |
$s=1; | |
$r=1; | |
while ($s <= $input) { | |
$r *= $s; | |
$s++; | |
} | |
if($input == 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function y = dot(a,b) | |
if length(a) == length(b) | |
size = length(a); | |
if size < 2 | |
error('The vectors size must greater than one'); | |
end; | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function y = distance(a,b) | |
if length(a) == length(b) | |
size = length(a); | |
if size < 2 | |
error('The vectors size must greater than one'); | |
end; | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function interpolation(x,y) | |
boyut = length(x); | |
for i=1:boyut | |
for j=1:boyut | |
if( j==1) mat(i,j) = 1; | |
continue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function threepoints(a,b,c) | |
if( length(a) ~= 3 || length(b) ~= 3 || length(c) ~= 3 ) | |
error('invalid points. points are like (x,y,z)'); | |
end; | |
v1 = b - a; | |
v2 = c - a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int gcd( int a, int b) | |
{ | |
int temp; | |
while(b>0) | |
{ | |
if(a>b) | |
{temp=a; | |
a=b; | |
b=temp;} |