Skip to content

Instantly share code, notes, and snippets.

View aivve's full-sized avatar

Aiwe aivve

View GitHub Profile
@aivve
aivve / integer_pow_log10.c
Created March 24, 2019 14:41
C integer pow() and log10()
// https://www.rookieslab.com/posts/fast-power-algorithm-exponentiation-by-squaring-cpp-python-implementation
#define MOD 1000000007
uint64_t fast_power(uint64_t base, uint64_t power) {
uint64_t result = 1;
while (power > 0) {
if (power % 2 == 1) { // Can also use (power & 1) to make code even faster
result = (result*base) % MOD;
}

Keybase proof

I hereby claim:

  • I am aivve on github.
  • I am aiwe (https://keybase.io/aiwe) on keybase.
  • I have a public key ASDPT6rXYbRuZqDnlqzvuxv1cZpZz3NcQi204rgH1DhOGgo

To claim this, I am signing this object: