Amstrad CPC bilgisayarı 2^128 hesaplıyor

ChatGPT ye Arduino için yazdırdığım programı Amstrad Basic diline chatGPT ye çevrttim ancak bir hata yaptı onuda düzelttim satır 160 INT eklnmesi gerekiyordu. Ayıca sonucu daha düzgün görmek için satır 240-270 ekledim. Alta programı görebilrsiniz

10 MODE 2:CLS
20 REM Define the number of digits required to store the result
30 DIM result(40)
40 FOR i=1 TO 40
50 result(i)=0
60 NEXT i
70 REM Set the first digit to 1
80 result(1)=1
90 REM Calculate 2^128 iteratively
100 FOR i=1 TO 128
110 carry=0
120 REM Multiply each digit of the result by 2 and add the carry from the previous digit
130 FOR j=1 TO 40
140 product=2*result(j)+carry
150 result(j)=product MOD 10
160 carry=INT(product/10)
170 NEXT j
180 NEXT i
190 REM Print the result
200 PRINT "2^128 = ";
210 FOR i=40 TO 1 STEP -1
220 PRINT result(i);
230 NEXT i
240 FOR i=40 TO 1 STEP -1
250 res$=res$+MID$(STR$(result(i)),2)
260 NEXT i
270 PRINT res$

Sonucuda Amtrad mükemmel şekilde hesapladı.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.