0
What is the output of this Pseudocode?
Hi, I need your help with this task: Input: Array A with the length |A|=n of the natural numbers a in N ^ >=1 Output: Boolean value x:= 0; For i:= 1 to n do x:= x + A[i]; End for If x<2 then Return false; End if For i:= 2 to x -1 do If x mod i=0 then Return false; End if End for Return true; 1) Question: what is the output of the algorithm with input Array [2,3,5,7] ? Is the output for 2 true? For 3 false? For 5 false? For 7 false? 2) what does the algorithm in general? Does it reduce the input in the loop and calculates if the mod is 0? So it is basically looking if the two numbers (one of them is reduced)are multiples of each other? I would really appreciate your help!
5 Answers
+ 1
ok changed the title. thanks for the remark.
Well, the question did not change. I kinda need help with solving this pseudocode so if anyone wants to help me with that, i would really appreciate it
0
Would anyone analyze the worst time complexity of this ?