basic algorithm program