Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exiting FOR NEXT, maybe a bug? Version 4.1.0 on Linux
#1
Had a go at calculating some Perfect Numbers. If I EXIT the FOR NEXT and print the number and the sum of it's factors (which should be equal) it works just fine. (After the first four it might take forever because it is a big number.) But if I print the number and the sum of it's factors just before I EXIT the FOR NEXT as well as after then I get several extra unrelated numbers. The line that causes the issue is commented out, but put it in and things go bad. I would have thought that it made no difference except for printing the numbers twice. What's going on? 

Code: (Select All)
ChDir startdir$ + "perfect numbers/"

Dim number As _Integer64
Dim trial As _Integer64
Dim div_total As _Integer64

number = 4 'start even and add 2 per pass
top:
div_total = 0

For trial = 1 To ((number / 2) + 1)
    If number Mod trial = 0 Then div_total = div_total + trial
    'If div_total = number Then Print number, div_total, "x": Exit For
Next trial

If div_total = number Then Print number, div_total
number = number + 2
GoTo top
Reply


Messages In This Thread
Exiting FOR NEXT, maybe a bug? Version 4.1.0 on Linux - by Circlotron - 05-08-2025, 12:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Make windows .exe using Linux version? Circlotron 7 509 01-15-2026, 09:42 PM
Last Post: ahenry3068
Question Latest version of QB64PE or QB64 compatible with Windows XP (32-bit)? madscijr 14 2,000 09-30-2025, 08:10 AM
Last Post: hsiangch_ong
  Linux Lubuntu INKEY$ issue TempodiBasic 7 647 09-09-2025, 02:53 PM
Last Post: hsiangch_ong
  Linux - file dialogue boxes... atl068 7 925 08-05-2025, 07:21 PM
Last Post: hsiangch_ong
  System Linux Chris 9 1,216 07-12-2025, 08:51 PM
Last Post: Chris

Forum Jump:


Users browsing this thread: 1 Guest(s)