How to eliminate for/if/while from algorithms when it's possible Is there any way to find out how to replace for/if for elementary recursive algorithms? I know that primitive recursive functions cannot basically eliminate "for", but for elementary recursive functions, there must be a way to convert the program into ones that do not have for/if/while and so on (which is elementary recursive).
For/if/while are the main blocks that will check for a condition. Since a recursive function will keep recurring until a condition is met, you will at least need an if statement to tell the function when to return. Otherwise, you will essentially be stuck in an infinite loop.