Archive/Numero_della_cabala/cabala.c
// We recurse through every single possible digit to find the one with the highest 
// number after modulo operation
We recurse through every single possible digit to find the one with the highest
number after modulo operation
We recurse through every single possible digit to find the one with the highest number after modulo operation
void recursive(int N, int n, long long M, long long calculated, int lastDigit) {
	if (n == N) return;
	for (int i = 3; i <= 9; i+=3) {
		if (i == lastDigit) continue;
		long long newCalc = calculated + (i * power(10, n));
		if (newCalc % M > maxMod) maxMod = newCalc % M;
		recursive(N, n + 1, M, newCalc, i);
	}
}
void recursive ( int N , int n , long long M , long long calculated , int lastDigit ) { if ( n == N ) return ; for ( int i = 3 ; i <= 9 ; i += 3 ) { if ( i == lastDigit ) continue ; long long newCalc = calculated + ( i * power ( 10 , n ) ) ; if ( newCalc % M > maxMod ) maxMod = newCalc % M ; recursive ( N , n + 1 , M , newCalc , i ) ; } }
We recurse through every single possible digit to find the one with the highest
number after modulo operation
We recurse through every single possible digit to find the one with the highest number after modulo operation