0
$\begingroup$

Apologies ahead of time, I don't fully understand what I'm asking...

But, is it possible to program using only 'while loops' and still be Turing equivalent?

Or more generally, can I do everything with 'while loops' that I could with 'if statements' and 'for loops'?

$\endgroup$
0

1 Answer 1

0
$\begingroup$

for(X; Y; Z) { Body; } is just syntax sugar for {X; while (Y) { Body; Z; }}.

if can be simulated easily: rewrite if (X) { Body; } as while (X) { Body; break; }.

$\endgroup$
1
  • $\begingroup$ So can I achieve Turing equivalency using only the 'while loop'? $\endgroup$
    – XYZandMe
    Commented Sep 18, 2018 at 16:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.