Talk:Loops/Increment loop index within loop body: Difference between revisions

m
no edit summary
(→‎increments the index such that the new index is now that prime: added reply and possibly a new task requirement wording.)
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 22:
Would this be satisfactory?     -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 00:29, 19 March 2019 (UTC)
 
:Works for me.--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 13:25, 21 March 2019 (UTC)
 
I had (originally) had wording in the task's requirements to make it clear(er)   (ha!, not so much)   that the index was to be (possibly ''also'') incremented   (by the computer program)   by the prime just found, but if done/interpreted another way and the index was incremented by the another "extra"   ''+1'',   (by   '''do'''   loop structure mechanism)   the new index   (a ''prime+prime'')   is never a prime, and if the index was incremented   (''+1'')   by the   '''do'''   loop structure mechanism,   no harm was done   (that is, at the worst, an extra check for primality was performed for the new index   ''prime+prime''   instead of   ''prime+prime+1''.   So the extra wording, as it turns out, wasn't necessary, but I wanted the incrementation to be clear.   So this almost (did?) became a   "Who's on first?"   sort of a word mess.     -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 00:29, 19 March 2019 (UTC)
 
:Well, I suppose the advantage of this description is that it indicates why you should not do this!, +1 for those imperative languages that prevent it--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 13:25, 21 March 2019 (UTC)
 
:: The task's requirements has been updated (to the above).     -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 07:54, 22 March 2019 (UTC)
 
To be clear, does this mean that the first Kotlin solution is an example of what isn't wanted? As I understand it, that solution checks if i is prime, and if it is, it replaces i with 2*i and then checks that. It looks like the Lua and Nanoquery solutions have the same issue, but I'm drifting away from languages that I know. --[[User:ReeceGoding|ReeceGoding]] ([[User talk:ReeceGoding|talk]]) 13:51, 23 June 2020 (UTC)
331

edits