In Chemistry we're learning about something called atomic decay series. If you don't know what this is please find out.

Actually, a full knowledge of this field of Chemistry is not really needed. My coding problem is that I am supposed to run the first loop section until the variable P is below or equal to 83. Once that happens the second loop runs, which adds 1 to P if (M-P)/P is above 1.51.

Anyways, I'm trying to make a program for it, but it's proving to be much harder than I expected.

I have a feeling that I shouldn't be using a while loop for the beta decay. However, I'm not sure exactly what I should do.

Since alpha decay has priority over beta decay, the loop for beta decay has to run until the proton count exceeds 83. But I can't find a way to cut the beta decay loop without stopping the entire program.

The above code works, but it runs the beta decay loop twice and then the program stops, presumably in an infinite loop.

For testing I have been using Thorium-232.

Please let me know if I can get some help.

Actually, a full knowledge of this field of Chemistry is not really needed. My coding problem is that I am supposed to run the first loop section until the variable P is below or equal to 83. Once that happens the second loop runs, which adds 1 to P if (M-P)/P is above 1.51.

Anyways, I'm trying to make a program for it, but it's proving to be much harder than I expected.

**Code:**```
```

ClrHome

"TLPBBIPOATRNFRRAACTHPAU NPPUAMCMBKCFES"->Str1

0->S

Disp "INPUT ELEMENT","(ATOM. NUM) AND","MASS NUMBER"

Input "MN: ",M

Input "E: ",P

ClrHome

Output(4,1,M

Output(6,1,P

Output(5,2,sub(Str1,2(P-80)-1,2

While P>83 and ((M-P)/P)>1.51

While P>83

Output(1,1,"ALPHA DECAY

Output(2,1,"Z>83

Output(4,1,M

Output(6,1,P

Output(5,2,sub(Str1,2(P-80)-1,2

Output(5,5,"--->

Output(4,9,"4

Output(6,9,"2

Output(5,9,"A +

M-4->M

P-2->P

Output(4,13,M

Output(6,13,P

Output(5,14,sub(Str1,2(P-80)-1,2

S+1->S

Output(8,1,S

Output(8,4,"STEPS TAKEN

Pause

End

While ((M-P)/P)>1.51

If P>83

End

Output(1,1,"BETA DECAY

Fix 2

Output(2,1,(M-P)/P

Float

Output(2,6,"N::P

Output(4,1,M

Output(6,1,P

Output(5,2,sub(Str1,2(P-80)-1,2

Output(5,5,"--->

Output(4,9,"0

Output(6,9,"-1

Output(5,9,"B +

P+1->P

Output(4,13,M

Output(6,13,P

Output(5,14,sub(Str1,2(P-80)-1,2

S+1->S

Output(8,1,S

Output(8,4,"STEPS TAKEN

Pause

End

End

ClrHome

Output(1,1,S

Output(3,1,"STEPS TAKEN.

Pause :ClrHome

I have a feeling that I shouldn't be using a while loop for the beta decay. However, I'm not sure exactly what I should do.

Since alpha decay has priority over beta decay, the loop for beta decay has to run until the proton count exceeds 83. But I can't find a way to cut the beta decay loop without stopping the entire program.

The above code works, but it runs the beta decay loop twice and then the program stops, presumably in an infinite loop.

For testing I have been using Thorium-232.

Please let me know if I can get some help.