program fibo; var a,b,c,i:integer; begin a:=1; b:=1; write(a:8,b:8); for i:=1 to 8 do begin c:=a+b; a:=b; b:=c; write(c:8) end; readln end.
-------------------------
program prim; var i,j,p,n:integer; begin writeln('Meddig irassuk ki a primeket?'); readln(n); for i:=2 to n do begin p:=0; for j:=2 to round(sqrt(i)) do if i mod j=0 then p:=1; if p=0 then write(i:8); end; readln end.
----------------------------
program lnko_s; var a,b,i,lnko,lkkt,c:integer; begin WriteLn('Kerem a ket szamot!'); ReadLn(a); ReadLn(b); if a<b then begin c:=a; a:=b; b:=c end; For i:=2 to a do if(a mod i=0) and (b mod i=0) then lnko:=i; lkkt:=round(a*b/lnko); WriteLn('Az lnko: ', lnko, ' Az lkkt: ', lkkt); ReadLn End.
--------------------------------
program erasztoteneszi_szita; const limit=10000; var t:array [1..limit] of boolean; i,j:word; begin for i:=1 to limit do t[i]:=true; i:=2; while i<=round(sqrt(limit)) do begin j:=2*i; while j<=limit do begin t[j]:=false; inc(j,i); end; inc(i); while not t[i] do inc(i); end; for i:=2 to limit do if t[i] then write(i:5); readln end.
-----------------------------
Nincsenek megjegyzések:
Megjegyzés küldése