-1
3
2,321
53
Top 1% !
Famous
Specified
Popularity: 7632nd place
Created
Modified Jan 13, 2016

### Published on:

No tags for this snippet yet.
 Language Java Source GitHub

# `Cálculo del dígito de control del código INE de municipio`

```Cálculo del dígito de control del código INE de municipio:
DigitoControl.java```
post this code
Copy Embed Code
``` <iframe id="embedFrame" style="width:600px; height:300px;" src="https://www.snip2code.com/Embed/997175/C-lculo-del-d-gito-de-control-del-c-digo?startLine=0"></iframe> ```
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public class DigitoControl { private static final int[][] magic = { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {0, 3, 8, 2, 7, 4, 1, 5, 9, 6}, {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} }; private static void getDigits(int num, int i, List<Integer> digits){ if(num != 0){ digits.add(num % 10); num /= 10; getDigits(num, i++, digits); } } public static int calc(int test) { List<Integer> digits = new ArrayList<Integer>(); getDigits(test, 0, digits); int sum = 0, n = digits.size(); for(int i = n; i > 0; i--){ sum+=magic[i % 3][digits.get(i-1)]; } return 10 - sum % 10; } public static void main(String[] args) { System.out.println(calc(26006)); } }