Skip to content

Instantly share code, notes, and snippets.

View vertexclique's full-sized avatar
🎛️
https://sptfy.com/QnOi

Theo M. Bulut vertexclique

🎛️
https://sptfy.com/QnOi
View GitHub Profile
# Newbie programmer
$input=<>;
sub factorial {
$s=1;
$r=1;
while ($s <= $input) {
$r *= $s;
$s++;
}
if($input == 0)
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
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
@vertexclique
vertexclique / distance.m
Created June 4, 2011 09:53
finding the distance between two vectors
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
@vertexclique
vertexclique / interpolation.m
Created June 4, 2011 09:52
Derive an equation from point like (x,y), its arguments are x=[x0,x1,...,yn] and y=[y0,y1,...,yn]
function interpolation(x,y)
boyut = length(x);
for i=1:boyut
for j=1:boyut
if( j==1) mat(i,j) = 1;
continue;
@vertexclique
vertexclique / threepoints.m
Created June 4, 2011 09:49
3 nokta alan ve bu noktaların oluşturduğu üçgenin alanı ve açılarını hesaplayan fonksiyon
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;
int gcd( int a, int b)
{
int temp;
while(b>0)
{
if(a>b)
{temp=a;
a=b;
b=temp;}