1) You have a syntax error. Line 41: }
Maybe when you copied the code?
2)
Running with "433156 474750 9491049193 316 274991 891051 832757 641261 441485 533035 849421 666272 782795 324942 607967 874404 882700 374884 749511 299960"
Your code is "recursive". That means: The procedure "divfiv" make a call to "divfiv". This is called a "nested" call.
In your program the "nested" call, makes another "nested nested" call to "divfiv". And a "nested nested nested ..... nested" call.
Every time, when "divfiv" is called, the computer must remember:
- from where it was called
- the values of all variables: numF , numA , numB, inds , cnter , lngt, numC , sum , enter
Because when "divfix" returns, the old values will be needed again.
Example
- running "divfiv" and sum= 123
- "divfiv" is calling "nested divfiv"
- sum:= 789
- "nested divfiv" ends, and returns to "divfiv"
- "divfiv" expects num=123
All this needs memory. The memory used for this is called "stack" or "callstack".
The "callstack" has a fixed size (fixed maximum amount of memory).
If this "stack" memory is full, the program crashes.
On my computer, the stack memory is full after 30000 "nested" calls.
Your program wants to make more than 100000 (hundred thousand) "nested" calls.
(I could not test more than that)
You can change that.
You do
divfiv (numF +1, numB , numC , inds , cnter , lngt );
Better do
repeat
...
else begin
numF := numF+1
numA := numB;
numB := numC
end;
until numC = 0;
This is not complete.
You have to write down (see below) what your code does.
Then you can see, what you need to change.
Print out your code on paper.
On each line, write the value of the variables.
See what happens.
- compare what happens when you do "divfiv (numF +1, " and when you do "repeat"
You can use the debugger, to get the values. But write them on a paper, together with each line of code.