Primitive Recursive Function for Division and Hailstone function

Are division and Hailstone primitive recursion function?

$$\text{Div}(x,y) = \begin{cases} x/y, & \text{if y divides x } \\ 0, & \text{otherwise} \end{cases}$$

$$\text{Hailstone}(n) =\begin{cases} 3n + 1, & \text{if n is odd } \\ n/2, & \text{if n is even} \end{cases}$$

I tried to solve division in this way $$\text{Div}(0,y) = 0$$ $$\text{Div}(x+y,y) = \text{Div}(x,y) + 1$$

I do not know how to proceed from here. Can anyone help me?

• This is essentially a programming question, if in a slightly atypical programming language. Community votes, please: is this ontopic? – Raphael Mar 16 '16 at 10:27
• Hint: you need to express all parts using primitive recursion. I see operations addition, multiplication and (integer) division, and predicates "divides", "is odd" and "is even", as well as (finite) case distinction. Some of these are probably known to be primitive recursive from lecture or prior exercise problems. Which are missing? – Raphael Mar 16 '16 at 10:29
• Regarding your attempt: that does not match the pattern for primitive recursion, at all. "$x+y$" is not something you get to do on the left-hand side. – Raphael Mar 16 '16 at 10:29
• For Div, it could also help to know that the bounded $\mu$ operator is primitive recursive. – Klaus Draeger Mar 16 '16 at 11:36
• @Raphael, I proved isodd,iseven,add,limited subtraction,divides,multiplication,modulo to be primitive recursive function. I know it should be Div(x+1,y) = F(Div(x,y)). I am not able to find that function(s).I thought maybe I could use Div(x+y,y) to get something. – Perseus14 Mar 16 '16 at 11:38

• Regarding the first two paragraphs of this answer: The function $\text{Div}(x,y)$ is defined if $y=0$ and $x>0$. We say $y$ divides $x$ iff there exists an integer $z$ such that $yz=x$. Thus, $0$ divides $x$ iff $x=0$. Therefore, when $x>0$, we have $\text{Div}(x,0)=0$. The only ambiguous case is $\text{Div}(0,0)$. I'd guess that the original poster means that $\text{Div}(0,0) = 0$. But if there is some doubt in your mind about that, I think it'd be more useful to post a comment requesting clarification, or suggest an edit to the question that defines $\text{Div}$ more carefully. – D.W. Mar 4 '17 at 1:14