import java io import java math import java util public class Class st

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.*;
import java.math.*;
import java.util.*;
public class Class {
static BigInteger one = BigInteger.ONE;
static BigInteger zero = BigInteger.ZERO;
static BigInteger two = BigInteger.valueOf(2);
static BigInteger sum (BigInteger a0, BigInteger n) {
BigInteger d = a0.multiply(n.subtract(one));
BigInteger num = d.add(a0.multiply(two));
BigInteger ret = num.multiply(n);
return ret.divide(two);
}
public static void main(String[] args) throws IOException
{
//PrintWriter pw = new PrintWriter(new File("output.txt"));
//Scanner sc = new Scanner (new File("input.txt"));
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
BigInteger n = sc.nextBigInteger();
BigInteger a = sc.nextBigInteger();
BigInteger b = sc.nextBigInteger();
BigInteger modulo = BigInteger.valueOf(1000000007);
BigInteger c = a.multiply(b);
BigInteger n1 = n.divide(a).subtract(n.mod(a) == zero ? one : zero);
BigInteger n2 = n.divide(b).subtract(n.mod(b) == zero ? one : zero);
BigInteger n3 = n.divide(c).subtract(n.mod(c) == zero ? one : zero);
BigInteger sum1 = sum(a, n1);
BigInteger sum2 = sum(b, n2);
BigInteger sum3 = sum(c, n3);
BigInteger ans = sum1.add(sum2).subtract(sum3);
pw.println(ans.mod(modulo));
sc.close();
pw.flush();
return;
}
}