public class Solution {

public int numberOfArithmeticSlices(int[] a) {

```
return totalSlices(0,a);
}
public int totalSlices(int i,int[] a){
if(a.length < 3) return 0;
if(a.length-i < 3 ) return 0;
int j =i+2;
int count =0;
while((i < a.length-2 && j < a.length) && (a[i]-a[i+1]) == ( a[j-1] - a[j])){
count++;
j++;
}
return count + totalSlices(i+1,a);
}
```

}