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 - Mensajes

#1 Publicado: 15/4/2025 19:43:22
David Daniel Alvarez Galvis

David Daniel Alvarez Galvis

1 me gusta en 9 mensajes.

Grupo: User

Software Jacobsen V1.sm (100,14 KiB) descargado 1832 vez(es).

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 Publicado: 16/4/2025 9:28:21
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: 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.

Editado 16/4/2025 9:49:28
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
A 4 usuarios les gustó este mensaje
Andrey Ivashov 16/4/2025 12:17:18, sergio 16/4/2025 16:08:42, NDTM Amarasekera 18/4/2025 11:04:52, David Daniel Alvarez Galvis 15/5/2025 19:30:46
#3 Publicado: 2/5/2025 18:19:15
David Daniel Alvarez Galvis

David Daniel Alvarez Galvis

1 me gusta en 9 mensajes.

Grupo: User

Hello, you're right. I made some changes that match what you suggested. I've already managed to solve the issues—thank you very much!
  • Nuevos mensajes
  • Sin mensajes nuevos