Math logic homework