Ticket #40620

TTL コマンドリファレンス intdim の例 (エラトステネスのふるい) について

Open Date: 2020-08-07 19:22 Last Update: 2020-08-07 19:22

Reporter:
(Anonymous)
Owner:
(None)
Type:
Status:
Open
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
None
File:
None
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

* https://ttssh2.osdn.jp/manual/4/ja/macro/command/intdim.html

* https://ttssh2.osdn.jp/manual/4/en/macro/command/intdim.html

こちら、実際に数えてみると 4 行目は [17 primes] であるはずです。よって 9 行目の count = 1count = 0 であるはずです。

  1. ; エラトステネスのふるい(sieve of Eratosthenes)
  2. ;
  3. ; Example of execution result
  4. ; 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 [18 primes]
  5. ;
  6. N = 30
  7. intdim flag N+1
  8. count = 1
  9. for i 0 N
  10. flag[i] = 1
  11. next
  12. for i 0 N
  13. if flag[i] =1 then
  14. count = count + 1
  15. p = 2 * i + 3
  16. sprintf "%d " p
  17. dispstr inputstr
  18. k = i + p
  19. while k <= N
  20. flag[k] = 0
  21. k = k + p
  22. endwhile
  23. endif
  24. next
  25. sprintf "[%d primes]" count
  26. dispstr inputstr
  27. end

以上、よろしくお願いいたします。

Ticket History (1/1 Histories)

2020-08-07 19:22 Updated by: None
  • New Ticket "TTL コマンドリファレンス intdim の例 (エラトステネスのふるい) について" created

Attachment File List

No attachments

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login