2
$\begingroup$

Is there a way to generate am expression that will get all integer multiples of an arbitrary pair of integers?

I.e. Some function that will spit out ${0,2,3,4,6,8,9,10, ... }$ and all of the other multiples of 2 and 3 given integer arguments. It should not generate results for integer arguments that are not multiples of 2 and 3.

By function I mean using elementary mathematical operations.

I would prefer a single variable expression.

  • 0
    Then it does not work for arbitrary $a$ and $b$2012-01-29

1 Answers 1

3

The function $f(n)={3\over2}n+{i^n-i^{-n}\over4i}$ (where $i$ is a square root of minus one) gives the outputs $0,2,3,4,6,8,9,10,\dots$ on being given the inputs $0,1,2,3,4,5,6,7,\dots$.

EDIT: In general, suppose you're given positive intgers $a,b$, and want the output to be all $n$ divisible by one or the other. First find the least common multiple $L$ of $a$ and $b$ (in the example, $L=6$). Then find the number $N$ of multiples of $a$ and/or $b$ in $0,1,2,\dots,L-1$ (in our example, $N=4$; in general, this is a simple exercise). The main term of $f(n)$ will be $(L/N)n$. The difference, $f(n)-(L/N)n$, will be periodic with period $N$, so it will be a linear combination of the functions $g_j(n)=e^{2\pi ijn/N}$, $j=0,1,\dots,N-1$. You find the coefficients in this linear combination by the standard techniques of intro linear algebra - it's just solving $N$ linear equations in $N$ unknowns.

  • 0
    How could I generalize this for arbitrary multiples?2012-01-29