1. ## Analysis of algorithms

hello,
i have problem with show correctness of these 2 algorithms:

alg1

prime(n)
q:=2; results:=true;
while (q< n and results) do
begin
if n mod q=0 then results:=false;
q := q + 1;
end;
if results then "prime number"
else "number isn't prime"

----------------------------------

alg2 (Factorial n!)

sil(n)
begin
sil := 1;
m := n;
while m > 0 do
begin
sil := sil*m;
m := m-1;
end;
end

2. I'm not sure what code that is, but in c syntax the factorial would be something like:

Code:
int n;
scanf("%d",&n);

int i,fact=1;

for(i=n;i=1;i--){
fact*=n
}

printf("%d",fact);

3. yes, these algorithms weren't write in c++. It is pseudocode. I have to show correctness these two algoritms using for example induction or Loop invariant ( Loop invariant - Wikipedia, the free encyclopedia ). It isn't important what code is this. It may be write in pascal, c++, java etc. For example we have here File:FlowchartExample.png - Wikipedia, the free encyclopedia factorial algoritms... but what is the proof that this algoritms is correct? I search proof for my two algoritms: factorial and prime number. I don't know how to do that. I have to do it for subject Analysis of algorithms