Advertisement
Centipede18

avoidObstaclesC

Apr 5th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. int avoidObstacles(std::vector<int> inputArray) {
  2.     for (int i = 2;; i++) {
  3.         bool found = true;
  4.         for (int t = 0; t < inputArray.size(); t++) {
  5.             if (inputArray[t] % i == 0) {
  6.                 found = false;
  7.                 break;
  8.             }
  9.         }
  10.         if (found) {
  11.             return i;
  12.         }      
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement