Advertisement
BlackHawke

Debug 3

Dec 5th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. public static bool ex3(int n)
  2. {
  3.     // FIXME expexted output: returns true if the number can be express as the sum of two primes
  4.     int i, f1 = 1, f2 = 1, j;  // Remove f3
  5.     for (i = 2; i < (n / 2) + 1; i++) // Change (n/2)+2 by (n/2)+1 | change i = 0 by i = 2
  6.     {
  7.         f1 = 1; // Change f1 = 0 by f1 = 1
  8.         f2 = 1; // Change f2 = 0 by f2 = 1
  9.         for (j = 2; j < i; j++) // Change j=4 by j=2
  10.         {
  11.             if (i % j == 0)
  12.             {
  13.                 f1 = 0;
  14.                 j = i;
  15.             }
  16.         }
  17.         for (j = 2; j < n - i; j++) // Change j = 0 by j = 2
  18.         {
  19.             if ((n - i) % j == 0) // Change (n-1) par (n-i)
  20.             {
  21.                 f2 = 0;
  22.                 j = n - i;
  23.             }
  24.         }
  25.         if (f1 == 1 && f2 == 1) // Change f1 == 0 by f1 == 2
  26.         {
  27.             return true;
  28.         }
  29.     }
  30.     // if (f3 == 1)
  31.     // {
  32.     //     return false;
  33.     // }
  34.     return false;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement