List of quadratic field with the UFD property Let D be a square free integer let $K=\mathbb{Q}(\sqrt{D})$ and let
$\mathcal{O_{K}}$ be the ring of integer of $K$
My question: where I can find a list of of the value of $D$ which makes the ring of the  quadratic field
$K=\mathbb{Q}(\sqrt{D})$ have the UFD property for $D<300$ ?
Can we check whether any value of $D$ make the the ring of a quadratic field have the UFD property using sage or magma ? if yes what is the command?
 A: The broken one-liner
L = [n for n in [2..300] 
     if n.is_squarefree() and QuadraticField(n, 'a').class_number() == 1]

computes in sage the list of all squarefree $n\le 300$, so that $\Bbb Q(\sqrt n)$ has class number one, this corresponds to the property of being UFD. Some first few entries in L are:
sage: L[:21]
[2, 3, 5, 6, 7, 11, 13, 14, 17, 19, 21, 22, 23, 29, 31, 33, 37, 38, 41, 43, 46]

Further checks in sage:
sage: K.<a> = QuadraticField(19)
sage: K
Number Field in a with defining polynomial x^2 - 19 with a = 4.358898943540674?
sage: K.class_number()
1
sage: K.OK()
Maximal Order in Number Field in a with defining polynomial x^2 - 19 with a = 4.358898943540674?
sage: K.OK().class_number()
1

In contrast:
sage: L.<b> = QuadraticField(34)
sage: L
Number Field in b with defining polynomial x^2 - 34 with b = 5.830951894845300?
sage: L.class_number()
2
sage: LOK = L.OK()
sage: LOK
Maximal Order in Number Field in b with defining polynomial x^2 - 34 with b = 5.830951894845300?
sage: LOK.class_number()
2
sage: L.class_group()
Class group of order 2 with structure C2 of Number Field in b with defining polynomial x^2 - 34 with b = 5.830951894845300?
sage: L.class_group().gens()
(Fractional ideal class (3, b + 1),)
sage: L.ideal(3)
Fractional ideal (3)
sage: L.ideal(3).factor()
(Fractional ideal (3, b + 1)) * (Fractional ideal (3, b + 2))
sage: L.ideal(29).factor()
(Fractional ideal (29, b + 11)) * (Fractional ideal (29, b + 18))

