Powers of 2:
2, 4, 8, 16, 32, 64, 128, 256...
Last digits:
2, 4, 8, 6, 2, 4, 8, 6...
Last digit of 2^i is:
int arr[4] = {2, 4, 8, 6};
return arr[(i-1)%4];
More Related Contents:
- Why was the space character not chosen for C++14 digit separators?
- Using paragraphs 8.5.3p4 and p5 in the C++11 Standard, how do I prove that the snippet below doesn’t compile?
- Please explain output from the `function1(p1,p2,p3);`
- What is different between *variable and variable* in c?
- How to call a parent class function from derived class function?
- C++: Life span of temporary arguments?
- using OpenCV and SVM with images
- C++ templates Turing-complete?
- C++11 allows in-class initialization of non-static and non-const members. What changed?
- What is the difference between “long”, “long long”, “long int”, and “long long int” in C++?
- Is string::c_str() no longer null terminated in C++11?
- How to write custom input stream in C++
- how does one securely clear std::string?
- Using AVX CPU instructions: Poor performance without “/arch:AVX”
- How to properly free the memory allocated by placement new?
- C++ where to initialize static const
- GetDIBits and loop through pixels using X, Y
- in C++ , what’s so special about “_MOVE_H”?
- Should I pass an std::function by const-reference?
- Reinterpret_cast vs. C-style cast
- C++ Get all bytes of a file in to a char array?
- What are good practices regarding shared libraries on Linux?
- Passing as const and by reference – Worth it? [duplicate]
- Memory Allocation char* and char[]
- Broken c++ std libraries on macOS High Sierra 10.13
- How to load a custom binary resource in a VC++ static library as part of a dll?
- Member function with static linkage
- What is difference between const and non const key?
- How to find Longest Common Substring using C++
- Are there any downsides to using UPX to compress a Windows executable?