g | x | w | all
Bytes Lang Time Link
091SAKO250326T173257ZAcrimori
039Forth gforth240909T175422Zreffu
043Setanta240908T173429Zbb94
004Nekomata240114T022254Zalephalp
025Ruby240907T020215ZJordan
077TSQL240208T161331ZSam CD
070Scratch240115T084914ZRhaixer
097TypeScript's type system240117T025722Znoodle p
018APLDyalog Unicode240117T022855ZYouserna
037TIBASIC240117T002324ZYouserna
008Jelly240114T152948ZNick Ken
037Perl 5 Minteger ap240116T212739ZXcali
051Funge98240116T055129ZAlt Shif
009x8632 machine code240115T225549ZPeter Co
00605AB1E240115T143217ZKevin Cr
023Charcoal240114T154844ZNeil
010Pyth240114T142651ZMukundan
013Uiua SBCS240114T013404Zchunes
027C gcc240114T121223ZG. Sliep
033R240114T115404ZNick Ken
035Retina 0.8.2240114T112856ZNeil
074Google Sheets240114T075000Zz..
047Go240114T051505Zbigyihsu
035Python 2240114T021158Zenzo
027JavaScript ES6240114T012421ZArnauld

SAKO, 91 bytes

PODPROGRAM:D(N,M)
CALKOWITE:N,M
1)A=MOD(N,M)
N=DIV(N,M)
M=A
GDYM>1:1,INACZEJ2
2)LINIIM
WROC

Prints a CR for 0 and LF for 1.

Full programme version, 92 bytes

CALKOWITE:N,M
CZYTAJ:N,M
1)A=MOD(N,M)
N=DIV(N,M)
M=A
GDYM>1:1,INACZEJ2
2)LINIIM
STOP2
KONIEC

Forth (gforth), 39 bytes

: f dup 1 > if /mod swap recurse then ;

Try it online!

Explanation

Pretty straightforward in forth. Recursive solution is fewer bytes because the non-recursive solution needs a loop in the form of begin while repeat, which adds an extra word.

Code Explanation

: f         \ begin word definition
  dup 1 >   \ duplicate remainder/divisor and check if it's greater than 1
  if        \ if it is, begin conditional code
    /mod    \ get the quotient and remainder from dividing the two numbers
    swap    \ reverse the stack elements because /mod uses the opposite order
    recurse \ call self recursively
  then      \ end conditional code
;           \ end word definition

Setanta, 43 bytes

gniomh f(a,b){ma b>1 b=f(a//b,a%b)toradh b}

try-setanta.ie link

Non-recursive solution, 51 bytes

gniomh(a,b){nuair-a b>1{c:=a//b b=a%b a=c}toradh b}

try-setanta.ie link

Nekomata, 4 bytes

ʷ{Ƶþ

Attempt This Online!

ʷ{Ƶþ
ʷ{      While; run the following code until it fails
  Ƶ       Check if the absolute value of the top of the stack is greater than 1
   þ      Divmod

Both Ƶ and þ are new built-ins in Nekomata 0.5.1.

Ruby, 25 bytes

F=->a,b{b>1?F[a/b,a%b]:b}

Attempt This Online!

T-SQL 77 bytes

declare @x int = 88, @y int = 7, @z int
while @y > 1 BEGIN
select @z = @x/@y, @y = @x-(@z*@y)
set @x = @z
end
select @y

Try it!

Scratch, 77 70 bytes

Ports @enzo's answer. Run without screen refresh.

define(x)(y
if<(y)>(1)>then
([floor v]of((x)/(y)))((x)mod(y
else
say(y

enter image description here

TypeScript's type system, 97 bytes

//@ts-ignore
type M<A,B,T=[]>=A extends[...B,...infer I]?M<I,B,[...T,1]>:A extends[1]|[]?A:M<T,A>

Try it at the TypeScript playground!

I/O is unary numbers / tuples of 1s.

Modified from my solution to Division and remainder.

APL(Dyalog Unicode), 18 bytes SBCS

{1<⍵:(⌊⍺÷⍵)∇⍵|⍺⋄⍵}

Try it on APLgolf!

A dfn that takes the first number as the left argument and the second number as the right argument.

TI-BASIC, 37 bytes

While 1<Ans(2
Ans→L
Ans(1)/Ans(2
int({Ans,ʟL(2)fPart(Ans
End
Ans(2

Takes input in Ans. Replace the second to fourth lines with int({Ans(1)/Ans(2),remainder(Ans(1),Ans(2 for -2 bytes if remainder( is supported.

Jelly, 8 bytes

d/ỊṪ¬Ɗ¿Ṫ

Try it online!

A monadic link taking a pair of non-negative integers and returning 1 or 0.

Explanation

     Ɗ¿  | While the following is true:
  Ị      | - <= 1
   Ṫ     | - Tail (i.e. second list member)
    ¬    | - Not
d/       | … Reduce using divmod
       Ṫ | Tail
 

If we were allowed to guarantee the second input were non-zero, this is shorter:

Jelly, 7 bytes

d/%/¿ṪỊ

Try it online!

Perl 5 -Minteger -ap, 37 bytes

@F=("@F"/$_,"@F"%$_)while($_=$F[1])>1

Try it online!

Funge-98, 51 bytes

v   >.@   @.<
>    "HTRF"4 (&& v
\/RRw1`1:%OOw1`1:<

Try it online!

x86-32 machine code, 9 bytes

x86-64 machine code, 10 bytes, same asm source

Args in EAX (dividend), ECX (divisor), return value in ECX (0 or 1 final remainder).

To call from C, gcc -mregparm=3 will put args in EAX, EDX, ECX in that order (so a dummy second arg works), but won't look for retval in ECX. Returning in EAX costs 1 extra byte for xchg eax,ecx at the end.

Args must be signed non-negative. (At least the dividend must be; the divisor can be full-range 32-bit unsigned. And the first remainder must also be non-negative). Divisor must be non-zero or the first iteration will fault.

               divmod_repeat:
               .loop:
 99               cdq        ; zero-extend (for numbers that fit as non-negative integers)
 F7F1             div ecx        ; EAX = EDX:EAX/ecx unsigned; EDX = remainder
                
 89D1             mov ecx, edx
 4A               dec edx        ; 1 byte instruction in 32-bit mode
 7FF8             jg .loop       ; }while(remainder-- > 1);   or  }while(--rem > 0)
 C3               ret            

               ;   cmp ecx, 2     ; simple but less golfed version
               ;   jae .loop      ; }while(new_divisor >= 2);

This shows a hexdump of the 32-bit machine code on the left, from a NASM listing. The x86-64 version (still using 32-bit operand-size) uses FFCA dec edx.

Not much scope for golfing, other than choosing a good calling convention. div only works with EDX:EAX / src, producing its outputs in EDX (remainder) and EAX (quotient). We don't want to touch quotient, so all the special-case accumulator short-form encodings of instructions like xchg eax, reg and cmp al, imm8.

But we can destroy the old copy of the remainder in EDX after copying it to ECX as the new divisor (or return value). So we can use 1-byte (in 32-bit mode) dec reg to set FLAGS instead of cmp. The next iteration's cdq will overwrite EDX anyway, and we need cdq anyway.

We can only use signed conditions with dec because it leaves CF unmodified, but is otherwise like sub or cmp ecx, 1.

05AB1E, 6 bytes

[`D!#‰

Try it online or verify all test cases.

Explanation:

[       # Start an infinite loop:
 `      #  Pop and push both values in the pair separately to the stack
        #  (which will use the implicit input-pair in the first iteration)
  D     #  Duplicate the top value (the remainder)
   !    #  Take its factorial (0 becomes 1; 1 remains 1; ≥2 becomes larger)
    #   #  If it's truthy (==1), stop the infinite loop
        #  (after which the duplicated remainder is output implicitly as result)
     ‰  #  (else) Divmod the two values

Charcoal, 23 bytes

NθNηW∧⊖ηη«≔﹪θιη≔÷θιθ»Iη

Try it online! Link is to verbose version of code. Explanation: Lack of divmod and recursion makes this annoyingly long.

NθNη

Input the two values.

W∧⊖ηη«

Compare the second value against both 1 and 0, but in such a way that if it is neither than the implicit loop variable has the same value.

≔﹪θιη≔÷θιθ

Modulo and divide the first value by the copy of the second, thus allowing the second and first values to be safely overwritten.

»Iη

Output the final value.

Pyth, 10 bytes

eu?>eG1.DF

Attempt This Online!

Uiua SBCS, 13 bytes

⊙◌⍢(:⌊⊃÷◿|>1)

Try it!

⊙◌⍢(:⌊⊃÷◿|>1)
  ⍢(     |  )  # while
          >1   # top of stack is greater than one
      ⊃÷◿      # quotient and remainder
     ⌊         # take the floor of the quotient
    :          # swap so remainder is on top
⊙◌             # drop the quotient from the stack

C (gcc), 27 bytes

f(a,b){a=b>1?f(a/b,a%b):b;}

Try it online!

R, 33 bytes

f=\(x,y)`if`(y>1,f(x%/%y,x%%y),y)

Attempt This Online!

A recursive function taking two arguments and returning 1 or 0.

Retina 0.8.2, 35 bytes

.+
$*
+`(..+)¶(\1)*(.*)
$3¶$#2$*
^.

Try it online! Takes the integers in reverse order on separate lines but link is to test suite that takes input in the format given in the question. Explanation:

.+
$*

Convert to unary.

(..+)¶(\1)*(.*)
$3¶$#2$*

If the denominator is at least 2, divmod the numerator by the denominator, replacing the denominator by the remainder and the numerator by the quotient.

+`

Repeat until the denominator is reduced to less than 2.

^.

Convert the denominator to 0 or 1.

Google Sheets, 74 bytes

=LET(F,LAMBDA(F,d,m,LET(x,MOD(d,m),IF(x<2,x,F(F,INT(d/m),x)))),F(F,A1,A2))

Simple recursive function that stops the execution when the remainder is 0 or 1.

Go, 47 bytes

func(a,b int)int{for b>1{a,b=a/b,a%b}
return b}

Attempt This Online!

Python 2, 35 bytes

f=lambda a,b:f(a/b,a%b)if b>1else b

Try it online!

JavaScript (ES6), 27 bytes

f=(p,q)=>q>1?f(p/q|0,p%q):q

Try it online!

Or 25 bytes with BigInts.