Xylem Number is a number whose sum of extreme (last and first) digits is equal to sum of it’s mean (all other digits except last and first) digits.
Phloem Number is a number which does not hold the above condition.
Example 1: 21201. 2+1 = 1+2+0. We observer sum of extremes and means are equal. Hence it is a Xylem Number.
Example 2: 21211. 2+1 != 1+2+1. Here sum of extremes and means are not equal. Hence it is a Phloem Number.
Java
import java.util.*;
public class XylemPhloemNumber
{
public static void main(String args[])
{
int n=0,r=0,temp=0,eSum=0,mSum=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
n=sc.nextInt();
temp=n;
while(temp>0)
{
r=temp%10;
if(temp==n||temp<10)
{
eSum=eSum+r;
}
else
{
mSum=mSum+r;
}
temp=temp/10;
}
if(eSum==mSum)
{
System.out.println(n+" is a Xylem Number");
}
else
{
System.out.println(n+" is a Phloem Number");
}
}
}Java