title: Checking if a number is a Happy Prime Number
body: <p>I have written a code which is used to check whether a number is happy prime number or not. Happy numbers are <a href="https://en.wikipedia.org/wiki/Happy_number" rel="nofollow noreferrer">these types of numbers.</a></p>
  
  <p>Here is an example of a happy number:</p>
  
  <p><a href="https://i.stack.imgur.com/srd8l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/srd8l.png" alt="enter image description here"></a></p>
  
  <p>In the end we are getting "1" that means it is a happy prime.</p>
  
  <p>Found my mistake, Thanks to @resueman But still there is one problem.
  It is not printing the output of the fourth input that is "4 1000"</p>
  
  <p>The new code is:</p>
  
  <pre><code>   import java.io.*;
  
  public class Contest {
  
  public static void main(String[] args) throws IOException {
  
          BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  
          int n = Integer.parseInt(reader.readLine());
          for(int m =n; m&gt;0; m--)
          {
              String s = reader.readLine();
              String[] sa = s.split(" ");
              String number = sa[1];
              int squareNumber;
              int orignialNum = Integer.parseInt(number);
  
              boolean isPrime = true;
              for(int i=2; i&lt;=orignialNum/2;i++)
              {
                  if(orignialNum % i == 0){
                      isPrime = false;
                  }
  
              }
              if(isPrime)
              {
                  if(orignialNum == 0 || orignialNum == 1 || orignialNum == 2 || orignialNum == 3)
                  {
                      System.out.println(sa[0]+" "+orignialNum+" "+"No");
                  }
                  else
                  {
                      squareNumber = orignialNum;
                      if(orignialNum&lt;10){
                          squareNumber = orignialNum*orignialNum;
                      }
  
                      int newNumber = check(squareNumber);
  
  
                      boolean isHappyNumber = isHappy(newNumber);
                      if(isHappyNumber)
                      {
                          System.out.println(sa[0]+" "+orignialNum+" "+"Yes");
                      }
                      else
                      {
                          System.out.println(sa[0]+" "+orignialNum+" "+"No");
                      }
                  }
              }
              else
              {
                  System.out.println(sa[0]+" "+orignialNum+" "+"No");
              }
  
          }
  
  }
  public static boolean isHappy(int n)
  {
      if(n==1)
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  public static int check(int n)
  {
          if(n&gt;9)
          {
              String sm = String.valueOf(n);
              String[] m = sm.split("");
              int[] a = new int[m.length];
              for(int i =0; i&lt;a.length; i++)
              {
                  a[i]= Integer.parseInt(m[i]);
  
              }
  
              for(int i =0; i&lt;a.length; i++)
              {
                  a[i]= a[i]*a[i];
  
              }
              int sum = 0;
  
              for(int i =0; i&lt;a.length; i++)
              {
                  sum = sum+a[i];
              }
              return check(sum);
          }
          else
          {
              return n;
          }
  }
  }
  </code></pre>
  
  <p>The first line will take the number of input it will take when executed.</p>
  
  <p>The input I am giving is:</p>
  
  <pre><code>4
  1 1
  2 7
  3 383
  4 1000
  </code></pre>
  
  <p>The output I am getting:</p>
  
  <pre><code>1 1 No
  2 7 Yes
  3 383 No
  </code></pre>
  
  <p>And the expected output is:</p>
  
  <pre><code>1 1 NO
  2 7 YES
  3 383 YES
  4 1000 NO
  </code></pre>
  
  <p>Somehow the 4th output is not appearing and for "383" it is 
  showing no.</p>
  
  <p>Please help.</p>