Search code examples
google-sheetslambdaarray-formulasgoogle-sheets-formula

How to use arrayformula with GCD?


I'm trying to use this formula to determine if Column A is a multiple of 5, but the arrayformula isn't expanding.

=ARRAYFORMULA(IF(GCD(5,A1:A)=5,TRUE,FALSE))

GCD doesn't seem to support arrayformula. How to make it work with ARRAYFORMULA?

Column C is the result of using autofill.

A B[Arrayformula] C[DragFill]
1 FALSE FALSE
2 FALSE
3 FALSE
4 FALSE
5 TRUE
6 FALSE
7 FALSE
8 FALSE
9 FALSE
10 TRUE
62 FALSE
34 FALSE
22 FALSE
75 TRUE
34 FALSE
46 FALSE
30 TRUE
21 FALSE
92 FALSE
56 FALSE

Solution

  • try:

    =BYROW(A1:A20, LAMBDA(x, GCD(5, x)=5))
    

    enter image description here

    or just:

    =INDEX(MOD(A1:A20, 5)=0)
    

    enter image description here