This question has already been solved: Start a new discussion instead

0

Hi guys, so yeah, I got some IT homework AGAIN on programs and I repeatedly did trace tables and they all worked, but somehow, when I enter it in turbo pascal, after the 10th number, the digits start to get negative and after the 6th number, its not following the sequence... Anyways, the question states: Write a program to generate the first 20 terms of the following sequence: 1,3,3,9,27,243,6561.........here's the program that I did:

```
program sequence;
uses wincrt;
var X,Y,Result,i:integer;
Begin
X:=1;
Y:=3;
Result:=X*Y;
Writeln(X);
Writeln(Y);
For i:=1 to 18 do
Begin
Y:=X;
X:=Result;
Result:=X*Y;
Writeln(Result);
End;
End.
```

Reputation Points: 1,420 [?]

Q&As Helped to Solve: 1,832 [?]

Skill Endorsements: 155 [?]

•Moderator

•
Featured

• Sponsor

0

In a way it makes sense!

An integer cannot hold numbers as big as 10^300 and higher, hence the negative values

You