TI-BASIC, 12 bytes
2=sum(not(fPart(Ans/randIntNoRep(1,Ans
Pretty straightforward. randIntNoRep(
gives a random permutation of all integers from 1 to Ans
.
This bends the rules a little; because lists in TI-BASIC are limited to 999 elements I interpreted
assume that the input can be stored in your data type
as meaning that all datatypes can be assumed to accommodate the input. Works fine for input of 1 to 255OP agrees with this interpretation.
A 17-byte solution which more clearly complies with the rulesactually works up to 10^12 or so:
2=Σ(not(fPart(Ans/A)),A,1,Ans