#include <stdio.h>
#include <stdlib.h>
#define MOD 1000000007
#define DEBUG 1
int main ( int argc , char * argv[] ) {
while ( 1 ) {
long long int a,b;
long long int result = 0;
scanf("%lld%lld" , &a,&b);
if ( a == 0 && b == 0 ) {
break;
}
long long int t = a;
int i = 0;
for ( i = 1 ; i <= b ; i++ ) {
result = (result + t) % MOD;
t = (t * a) % MOD;
}
printf("%lld\n" , result);
}
return 0;
}
Arpit's Newsletter read by 15000+ engineers
🔥 Thrice a week, in your inbox, an essay about system design, distributed systems, microservices, programming languages internals, or a deep dive on some super-clever algorithm, or just a few tips on building highly scalable distributed systems.