Vitamin B3 (niacin) prevents and treats pellagra, a disease caused by niacin deficiency characterized by diarrhea, dementia, and skin rashes. Niacin can be obtained from foods like meat, fish, eggs, and legumes. Vitamins A, D, and B6 serve different functions in the body and do not prevent pellagra.