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 8 characters in body
Source Link
mudkip201
  • 993
  • 1
  • 6
  • 10

Pyt, 37(削除) 37 (削除ここまで) 35 bytes

←Đ0⇹`25*61+Đ1⇹ɾ⇹1⇹ɾǤ1=⇹3Ș+⇹1-łŕ⇹6*⇹←Đ0⇹`25*6+Đ1⇹ɾ⇹1⇹ɾǤ1=⇹3Ș+⇹−łŕ⇹6*⇹/√
←Đ Push input onto stack twice
 0 Push 0
 ⇹ Swap top two elements of stack
 ` ł ł Repeat until top of stack is 0
 25*61+Đ1⇹ɾ⇹1⇹ɾ25*6+Đ1⇹ɾ⇹1⇹ɾ  Randomly generate two integers in the range [1,10^6]
 Ǥ1= Is their GCD 1?
 ⇹3Ș Reposition top three elements of stack
 + Add the top 2 on the stack
 ⇹− ⇹1- Swap the top two and subtract one from the new top of the stack
 ŕ ŕ Remove the counter from the stack
   Swap the top two on the stack
 6* 6* Multiply top by 6
   Swap top two
 / / Divide the second on the stack by the first
   Get the square root

Pyt, 37 bytes

←Đ0⇹`25*61+Đ1⇹ɾ⇹1⇹ɾǤ1=⇹3Ș+⇹1-łŕ⇹6*⇹/√
←Đ Push input onto stack twice
 0 Push 0
 ⇹ Swap top two elements of stack
 ` ł Repeat until top of stack is 0
 25*61+Đ1⇹ɾ⇹1⇹ɾ Randomly generate two integers in the range [1,10^6]
 Ǥ1= Is their GCD 1?
 ⇹3Ș Reposition top three elements of stack
 + Add the top 2 on the stack
 ⇹1- Swap the top two and subtract one from the new top of the stack
 ŕ Remove the counter from the stack
  Swap the top two on the stack
 6* Multiply top by 6
  Swap top two
 / Divide the second on the stack by the first
  Get the square root

Pyt, (削除) 37 (削除ここまで) 35 bytes

←Đ0⇹`25*6+Đ1⇹ɾ⇹1⇹ɾǤ1=⇹3Ș+⇹−łŕ⇹6*⇹/√
←Đ Push input onto stack twice
 0 Push 0
 ⇹ Swap top two elements of stack
 ` ł Repeat until top of stack is 0
 25*6+Đ1⇹ɾ⇹1⇹ɾ  Randomly generate two integers in the range [1,10^6]
 Ǥ1= Is their GCD 1?
 ⇹3Ș Reposition top three elements of stack
 + Add the top 2 on the stack
 ⇹− Swap the top two and subtract one from the new top of the stack
 ŕ Remove the counter from the stack
  Swap the top two on the stack
 6* Multiply top by 6
  Swap top two
 / Divide the second on the stack by the first
  Get the square root
Source Link
mudkip201
  • 993
  • 1
  • 6
  • 10

Pyt, 37 bytes

←Đ0⇹`25*61+Đ1⇹ɾ⇹1⇹ɾǤ1=⇹3Ș+⇹1-łŕ⇹6*⇹/√

Explanation:

←Đ Push input onto stack twice
 0 Push 0
 ⇹ Swap top two elements of stack
 ` ł Repeat until top of stack is 0
 25*61+Đ1⇹ɾ⇹1⇹ɾ Randomly generate two integers in the range [1,10^6]
 Ǥ1= Is their GCD 1?
 ⇹3Ș Reposition top three elements of stack
 + Add the top 2 on the stack
 ⇹1- Swap the top two and subtract one from the new top of the stack
 ŕ Remove the counter from the stack
 ⇹ Swap the top two on the stack
 6* Multiply top by 6
 ⇹ Swap top two
 / Divide the second on the stack by the first
 √ Get the square root

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