Write the following functions, using for, while, and repeat loops.( using R program)
a. input: a number and a vector, output: the (first) position of the number in the vector
b. input: a number x, output: the first n Natural numbers which sum is more than x
a ans:
a<-function(number,vector){
for(i in 1:length(vector)){
if(vector[i]==number){
return(i)
}
}
}
cat("The position:",a(1,c(0,2,1,3,1,4)))

#output:

b ans:
natural<-function(x){
sum=1
i=0
repeat{
if(sum>x){
break
}
else{
sum=sum+i
i=i+1
}
}
for(m in 1:i){
print(m)
}
}
natural(7)

#output:

#if you have any doubt comment below.if you like give thumbs up...
Write the following functions, using for, while, and repeat loops.( using R program) a. input: a...