public class SloveniaNationalIdentificationNumber
public static void Main()
bool isValid = isValidSNIN("0101006500006");
Console.WriteLine(isValid);
private static bool authenticateMonth(int month)
if (month >= 1 && month <= 12) return true;
private static bool authenticateDate(int date)
if (date < 1 || date > 31) return false;
private static bool authenticateConstant(int c)
if (c != 50) return false;
private static int getReminder(string snin)
for (int i=0;i<(snin.Length/2);i++)
addition += ((Convert.ToInt32(snin[i]) - 48) + (Convert.ToInt32(snin[(snin.Length / 2)+ i]) - 48)) * (7 - i);
int answer = 11 - addition % 11;
if (answer == 10 || answer == 11) return 0;
private static bool isValidSNIN(string snin)
if (snin.Length != 13) return false;
if (char.IsLetter(ch)) return false;
int date = Convert.ToInt32(snin.Substring(0,2));
if (!authenticateDate(date)) return false;
int month = Convert.ToInt32(snin.Substring(2,2));
if (!authenticateMonth(month)) return false;
int constant = Convert.ToInt32(snin.Substring(7,2));
if (!authenticateConstant(constant)) return false;
int wholestring_check = Convert.ToInt32(snin[snin.Length - 1]) - 48;
string wholestring = snin.Substring(0,snin.Length - 1);
int wholestring_reminder = getReminder(wholestring);
if (wholestring_reminder != wholestring_check) return false;