Java
public static void rotate(int[] arr, int by) {
int n = arr.length;
int i = 0;
int j = 0;
while (i < n) {
int k = j;
int value = arr[k];
do {
k = (k + by) % n;
int tmp = arr[k];
arr[k] = value;
value = tmp;
i++;
} while (k != j);
j++;
}
}
Demo here.