Cod sursa(job #42697)

Utilizator Bluedrop_demonPandia Gheorghe Bluedrop_demon Data 29 martie 2007 14:00:01
Problema Fractii Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.26 kb
{
    Problema fractii
}

Program fractii;

Type vector = array[1..1000000] of Longint;

Var n, i, j, l, aux : Longint;
    c : vector;
    nr : int64;
    cod : boolean;

Begin
    Assign( input, 'fractii.in' );
    Reset( input );
        Readln( n );
    Close( input );

    nr := n shl 1;
    nr := nr-1;

{    For i := 2 to n do
        if c[i] = 0 then
            Begin
                aux := i;
                j := aux;
                While j <= n do
                    Begin
                        j := j+aux;
                        c[j] := 1;
                    End;
            End;
}
    For i := 2 to n do
        Begin
        For j := 2 to i-1 do
            Begin
            l := 1;
            cod := true;
            While l < j do
                Begin
                    l := l+1;
                    if ( i mod l = 0 ) and ( j mod l = 0 )
                        then
                        Begin
                            cod := false;
                            break;
                        End;
                End;
            if cod then nr := nr+2;
            End;
        End;

    Assign( output, 'fractii.out' );
    Rewrite( output );
        Writeln( nr );
    Close( output );
End.