It doesn't matter if you do it in pencil, in maths exams they tell you to write in pencils for graphs anyway.
They tell you to do it in black pen, because when they mark/moderate the exams, sometimes they photocopy them, so writing in black photocopies more easily.