Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#C, 77 bytes

C, 77 bytes

-2 bytes for removing redundant braces (* is associative).

r,t;f(a,b){t=1;r=0;while(a|b)r+=t*(a%10)*(b%10),a/=10,b/=10,t*=100;return r;}

t=1,100,10000,... is used for padding. As long as a or b is not zero keep multiplicating the last digit %10 with t and accumulate. Then erease the last digit of a and b (/=10) and shift t by 2 digits (*=100).

Ungolfed and usage:

r,t;
f(a,b){
 t=1;
 r=0;
 while(a|b)
 r+=t*(a%10)*(b%10),
 a/=10,
 b/=10,
 t*=100;
 return r;
}
main(){
 printf("%d\n", f(1276,933024));
}

#C, 77 bytes

-2 bytes for removing redundant braces (* is associative).

r,t;f(a,b){t=1;r=0;while(a|b)r+=t*(a%10)*(b%10),a/=10,b/=10,t*=100;return r;}

t=1,100,10000,... is used for padding. As long as a or b is not zero keep multiplicating the last digit %10 with t and accumulate. Then erease the last digit of a and b (/=10) and shift t by 2 digits (*=100).

Ungolfed and usage:

r,t;
f(a,b){
 t=1;
 r=0;
 while(a|b)
 r+=t*(a%10)*(b%10),
 a/=10,
 b/=10,
 t*=100;
 return r;
}
main(){
 printf("%d\n", f(1276,933024));
}

C, 77 bytes

-2 bytes for removing redundant braces (* is associative).

r,t;f(a,b){t=1;r=0;while(a|b)r+=t*(a%10)*(b%10),a/=10,b/=10,t*=100;return r;}

t=1,100,10000,... is used for padding. As long as a or b is not zero keep multiplicating the last digit %10 with t and accumulate. Then erease the last digit of a and b (/=10) and shift t by 2 digits (*=100).

Ungolfed and usage:

r,t;
f(a,b){
 t=1;
 r=0;
 while(a|b)
 r+=t*(a%10)*(b%10),
 a/=10,
 b/=10,
 t*=100;
 return r;
}
main(){
 printf("%d\n", f(1276,933024));
}
added 230 characters in body
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31

#C, 77 bytes

-2 bytes for removing redundant braces (* is associative).

r,t;f(a,b){t=1;r=0;while(a|b)r+=t*(a%10)*(b%10),a/=10,b/=10,t*=100;return r;}

t=1,100,10000,... is used for padding. As long as a or b is not zero keep multiplicating the last digit %10 with t and accumulate. Then erease the last digit of a and b (/=10) and shift t by 2 digits (*=100).

Ungolfed and usage:

r,t;
f(a,b){
 t=1;
 r=0;
 while(a|b)
 r+=t*(a%10)*(b%10),
 a/=10,
 b/=10,
 t*=100;
 return r;
}
main(){
 printf("%d\n", f(1276,933024));
}

#C, 77 bytes

-2 bytes for removing redundant braces (* is associative).

r,t;f(a,b){t=1;r=0;while(a|b)r+=t*(a%10)*(b%10),a/=10,b/=10,t*=100;return r;}

Ungolfed and usage:

r,t;
f(a,b){
 t=1;
 r=0;
 while(a|b)
 r+=t*(a%10)*(b%10),
 a/=10,
 b/=10,
 t*=100;
 return r;
}
main(){
 printf("%d\n", f(1276,933024));
}

#C, 77 bytes

-2 bytes for removing redundant braces (* is associative).

r,t;f(a,b){t=1;r=0;while(a|b)r+=t*(a%10)*(b%10),a/=10,b/=10,t*=100;return r;}

t=1,100,10000,... is used for padding. As long as a or b is not zero keep multiplicating the last digit %10 with t and accumulate. Then erease the last digit of a and b (/=10) and shift t by 2 digits (*=100).

Ungolfed and usage:

r,t;
f(a,b){
 t=1;
 r=0;
 while(a|b)
 r+=t*(a%10)*(b%10),
 a/=10,
 b/=10,
 t*=100;
 return r;
}
main(){
 printf("%d\n", f(1276,933024));
}
Source Link
Karl Napf
  • 4.5k
  • 14
  • 31

#C, 77 bytes

-2 bytes for removing redundant braces (* is associative).

r,t;f(a,b){t=1;r=0;while(a|b)r+=t*(a%10)*(b%10),a/=10,b/=10,t*=100;return r;}

Ungolfed and usage:

r,t;
f(a,b){
 t=1;
 r=0;
 while(a|b)
 r+=t*(a%10)*(b%10),
 a/=10,
 b/=10,
 t*=100;
 return r;
}
main(){
 printf("%d\n", f(1276,933024));
}

AltStyle によって変換されたページ (->オリジナル) /