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

Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars

a,b=map(int,input().split())
t,g='',1
while g<a:
 g,p=g+1,0
 if a%g+b%g<1:
 while a%g+b%g<1:a/=g;b/=g;p+=1
 t+='%d^%d '%(g,p)
print(t)

#Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars a,b=map(int,input().split()) t,g='',1 while g<a: g,p=g+1,0 if a%g+b%g<1: while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) print(t) It'sIt's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

#Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars a,b=map(int,input().split()) t,g='',1 while g<a: g,p=g+1,0 if a%g+b%g<1: while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) print(t) It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars

a,b=map(int,input().split())
t,g='',1
while g<a:
 g,p=g+1,0
 if a%g+b%g<1:
 while a%g+b%g<1:a/=g;b/=g;p+=1
 t+='%d^%d '%(g,p)
print(t)

It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

added 5 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14

#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) 137(削除) 137 (削除ここまで) 136 chars a,b=map(int,input().split()) t,g='',21 while g<a: g,p=g+1,0 if a%g+b%g<1: p=0 while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) g+=1 print(t) It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) 137 chars a,b=map(int,input().split()) t,g='',2 while g<a: if a%g+b%g<1: p=0 while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) g+=1 print(t) It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) 136 chars a,b=map(int,input().split()) t,g='',1 while g<a: g,p=g+1,0 if a%g+b%g<1: while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) print(t) It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

added 6 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14

#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) 142(削除) 142 (削除ここまで) 137 chars a,b=map(int,input().split()) t,g='',2 while g<a: if a%g+b%g<1: p=0 while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) else:g+=1 print(t) It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) 142 chars a,b=map(int,input().split()) t,g='',2 while g<a: if a%g+b%g<1: p=0 while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) else:g+=1 print(t) It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) 137 chars a,b=map(int,input().split()) t,g='',2 while g<a: if a%g+b%g<1: p=0 while a%g+b%g<1:a/=g;b/=g;p+=1 t+='%d^%d '%(g,p) g+=1 print(t) It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.

added 137 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
added 45 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
deleted 2 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
deleted 37 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
added 3 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
deleted 8 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
deleted 9 characters in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
deleted 1 character in body
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
undoing last edit, i had a mistake
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading
Source Link
Tal
  • 1.4k
  • 8
  • 14
Loading

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