Nested loops take time to execute.

Nested loops take time to execute. - I have a calculation with several nested For and While loops, but the execution takes too long - Messages

#1 Posted: 4/15/2025 7:43:22 PM
David Daniel Alvarez Galvis

David Daniel Alvarez Galvis

0 likes in 2 posts.

Group: User

Software Jacobsen V1.sm (100 KiB) downloaded 75 time(s).

Hi everyone,
I have a calculation with several nested FOR and WHILE loops, but the execution is taking too long. I don’t know what the issue is.
Also, I don’t know how to extract the variables SIGA and SIGT from the IF statements inside the loops.
Thanks in advance for your time and help.
#2 Posted: 4/16/2025 9:28:21 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Hello,

I've put some trace() "traps" in your code and it seems that there is some logic issue at least in the while(k<=1) level.

2025-04-16 11_21_29-SMath Solver - [Software Jacobsen V1.sm_].png

First issue is that k is never initialized.

Second issue is that the first if() inside that while() sends the algorithm in an endless loop, since k doesn't change up to that point.

2025-04-16 11_21_49-SMath Solver - [Software Jacobsen V1.sm_].png

There might be more problems but I'll start from those.

Edited 4/16/2025 9:49:28 AM
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
3 users liked this post
Andrey Ivashov 4/16/2025 12:17:18 PM, sergio 4/16/2025 4:08:42 PM, NDTM Amarasekera 4/18/2025 11:04:52 AM
  • New Posts New Posts
  • No New Posts No New Posts