Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
using namespace std;
int arr[4] = {6, 8, 4, 2};
int main() {
int n;
cin >> n;
if(n == 0)
cout << 1 << endl;
else
cout << arr[n % 4] << endl;
return 0;
}
Copy The Code &
Try With Live Editor
Input
1
Output
8
Demonstration
Codeforces Solution-Arpa’s hard exam and Mehrdad’s naive chea-Solution in C, C++, Java, Python