FAQ | Points | Add... | Recent posts | Search | Register | Log in


[Turbo Pascal] Silnia.


Post new topic  This topic is locked      Main Page -> Forum Index -> Programming Generally -> [Turbo Pascal] Silnia.
Author
Message
Tomaszow
Poziom 2
Poziom 2


Joined: 13 Apr 2004
Posts: 2

Post#1 Post from the author of the topic 13 Apr 2004 21:59   

[Turbo Pascal] Silnia.


Nie mam pojęcia jak zrobić program podający silnię danej liczby w Turbo Pascalu. Proszę o pomoc.

Zamykam. - arnoldziq
Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 13 Apr 2004 21:59   





Back to top
   
elektryk
Poziom 26
Poziom 26


Joined: 25 Apr 2002
Posts: 11092

Post#2 13 Apr 2004 22:26   

Re: Silnia w Turbo Pascalu


Możesz zrobić na dwa sposoby rekurencyjnie albo w pętli, oba wg wzoruk książkowego.
Back to top
   
Google

Google Adsense


Post# 13 Apr 2004 22:26   





Back to top
   
Leap
Poziom 16
Poziom 16


Joined: 28 May 2003
Posts: 306
Location: Morąg

Post#3 13 Apr 2004 22:49   

Re: Silnia w Turbo Pascalu


uses crt;
var wynik:integer;
x,y:integer;
begin
wynik:=1;
write('Podaj z jakiej liczby silnia ? :');
readln(x);
for y:=1 to x do wynik:=wynik*y;
writeln('Silnia tej liczby to :',wynik);
end.


moze bedzie trzeba wziasc wynik innego typu zmiennych gdy silnia bedzie za duza.
Back to top
   
Google

Google Adsense


Post# 13 Apr 2004 22:49   





Back to top
   
jiwaniuk
Poziom 20
Poziom 20


Joined: 14 Dec 2002
Posts: 1085
Location: Gdynia

Post#4 13 Apr 2004 22:59   

Re: Silnia w Turbo Pascalu


Oto przykład funkcji obliczającej silnię:

FUNCTION silnia(n: integer): integer;
BEGIN
IF n = 0 THEN silnia := 1
ELSE silnia := n*silnia(n - 1)
END;

Pozdrawiam wszystkich

jjanek
Back to top
   
Tomaszow
Poziom 2
Poziom 2


Joined: 13 Apr 2004
Posts: 2

Post#5 Post from the author of the topic 14 Apr 2004 18:40   

Silnia w Turbo Pascalu


thx
Back to top
   
Post new topic  This topic is locked      Main Page -> Forum Index -> Programming Generally -> [Turbo Pascal] Silnia.
Page 1 of 1
Similar topics
Turbo pascal - kalkulator (4)
turbo pascal - KALKULATOR (3)
Turbo Pascal i komendy AT (5)
Co do poprawki ? Turbo Pascal... (4)
potęga w Turbo Pascal (5)
[Turbo Pascal] Sortowanie. (4)
[Turbo Pascal] Error 36 pascal (15)
Co lepsze Turbo Pascal 7.0 czy Free Pascal (FPC 2.0) (10)
Turbo pascal - dodawanie (7)
[Turbo Pascal] Kompilator (9)

Page generation time: 0.105 seconds


FAQ || Administrator || Moderators || Widgets and banners || Contact
elektroda.pl topic RSS feed