Autor Beitrag
SMARTY1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 18.09.07 16:00 
Hallo
Unser Lehrer hat uns die Aufgabe gegeben ein Programm zu erstellen, das die Summe
s(n)=1+1/2+1/3+1/4.....1/n für ein einzugebendes n Element N berechnet und ausgibt!
Habt ihr eine Ahnung was die Rechnung berechnen soll? Wie kann ich das mit Delphi machen?


Moderiert von user profile iconGausi: Topic aus VCL (Visual Component Library) verschoben am Di 18.09.2007 um 17:19
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8553
Erhaltene Danke: 479

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 18.09.07 16:18 
Hallo und :welcome: in der Entwickler-Ecke!

Da sind wohl mal ein paar Grundlagen nötig...eine einfache For-Schleife, die etwas ähnliches macht, sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var Ergebnis, i :Integer;
begin
  Ergebnis := 0;
  for i := 1 to n do
    Ergebnis := Ergebnis + i;
end;

Für dein Problem musst du das etwas modifizieren - das schwierigste dürfte sein, dass die Variable Ergebnis dann kein Integer sein darf, sondern ein Float-Typ wie Double sein muss ;-)

_________________
We are, we were and will not be.
SMARTY1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 18.09.07 16:21 
Hey danke ich probierts gleich mal aus!