Cody

Problem 1278. Find the nearest integer

Created by Bruce Raine in Community

Given a vector of integers and a real number find the closest integer.

EX:

>> a = [2 4 5 6 8 10];

>> b = 4.6;

>> nearestNumber(a,b)

ans=5

Solution Stats

59.31% Correct | 40.69% Incorrect
Last solution submitted on Apr 18, 2019

Problem Comments