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

added 25 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Python 2/3, (削除) 220 (削除ここまで) 202(削除) 202 (削除ここまで)(削除) 195 (削除ここまで) 183 bytes

g=lambda a,b:a and g(b%a,a)or b
def f(nb;n,dd=input():
 m=[];c=[];m=c=()
while n+d>2:
 t=n*d;f=p=2
 while t>p:
 if	if t%p:p+=1;f*=p
 else	else:t/=p
 if n%p:c+=[p];n*=fc+=p,;n*=f
 else:m+=[p];d*=fm+=p,;d*=f
 t=g(n,d);n/=t;d/=t
print return[mm,c]c

Try it online! Try it online! Edit: Saved 18(削除) 18 (削除ここまで) 25 bytes thanks to @Mr.Xcoder. Saved 12 bytes thanks to @JonathanFrech.

Python 2/3, (削除) 220 (削除ここまで) 202 bytes

g=lambda a,b:a and g(b%a,a)or b
def f(n,d):
 m=[];c=[]
while n+d>2:
 t=n*d;f=p=2
 while t>p:
 if t%p:p+=1;f*=p
 else:t/=p
 if n%p:c+=[p];n*=f
 else:m+=[p];d*=f
 t=g(n,d);n/=t;d/=t
 return[m,c]

Try it online! Edit: Saved 18 bytes thanks to @Mr.Xcoder.

Python 2, (削除) 220 (削除ここまで) (削除) 202 (削除ここまで)(削除) 195 (削除ここまで) 183 bytes

g=lambda a,b:a and g(b%a,a)or b;n,d=input();m=c=()
while n+d>2:
 t=n*d;f=p=2
 while t>p:
	if t%p:p+=1;f*=p
	else:t/=p
 if n%p:c+=p,;n*=f
 else:m+=p,;d*=f
 t=g(n,d);n/=t;d/=t
print m,c

Try it online! Edit: Saved (削除) 18 (削除ここまで) 25 bytes thanks to @Mr.Xcoder. Saved 12 bytes thanks to @JonathanFrech.

added 418 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Python 2/3, 220(削除) 220 (削除ここまで) 202 bytes

g=lambda a,b:a and g(b%a,a)or b
def f(n,d):
 m=[];c=[]
 while n+d>2:
 t=n*d;f=p=2
 while t>p:
 if t%p:p+=1;f*=p
 else:t/=p
 if n%p:c+=[p];n*=f
 else:m+=[p];d*=f
 t=g(n,d);n/=t;d/=t
 return[m,c]
g=lambda a,b:a and g(b%a,a)or b
def f(n,d):
 m=[];c=[]
 while n+d>2:
 t=n*d;f=p=2
 while t>p:
 if t%p:
 p+=1;f*=p
 else:
 t/=p
 if n%p:
 c+=[p];n*=f
 else:
 m+=[p];d*=f
 t=g(n,d);n/=t;d/=t
 return[m,c]

Try it online! Edit: Saved 18 bytes thanks to @Mr.Xcoder.

Python 2, 220 bytes

g=lambda a,b:a and g(b%a,a)or b
def f(n,d):
 m=[];c=[]
 while n+d>2:
 t=n*d;f=p=2
 while t>p:
 if t%p:
 p+=1;f*=p
 else:
 t/=p
 if n%p:
 c+=[p];n*=f
 else:
 m+=[p];d*=f
 t=g(n,d);n/=t;d/=t
 return[m,c]

Python 2/3, (削除) 220 (削除ここまで) 202 bytes

g=lambda a,b:a and g(b%a,a)or b
def f(n,d):
 m=[];c=[]
 while n+d>2:
 t=n*d;f=p=2
 while t>p:
 if t%p:p+=1;f*=p
 else:t/=p
 if n%p:c+=[p];n*=f
 else:m+=[p];d*=f
 t=g(n,d);n/=t;d/=t
 return[m,c]

Try it online! Edit: Saved 18 bytes thanks to @Mr.Xcoder.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Python 2, 220 bytes

g=lambda a,b:a and g(b%a,a)or b
def f(n,d):
 m=[];c=[]
 while n+d>2:
 t=n*d;f=p=2
 while t>p:
 if t%p:
 p+=1;f*=p
 else:
 t/=p
 if n%p:
 c+=[p];n*=f
 else:
 m+=[p];d*=f
 t=g(n,d);n/=t;d/=t
 return[m,c]

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