Saturday, January 3, 2026

Spy number, Neon number, Buzz number and Armstrong numbers.

 Spy number

A spy number is a positive integer that holds a special property. To be a spy number, the sum of all the digits in the number must be equal to the product of all the digits. Let's break this down further.


When we talk about the sum of digits, we mean adding up each individual digit in the number. For example, if we have the number 1124, the sum of its digits would be 1 + 1 + 2 + 4 = 8.


On the other hand, the product of digits means multiplying all the digits together. Using the same example of 1124, the product of its digits would be 1 x 1 x 2 x 4 = 8.


For a number to be a spy number, the sum of its digits and the product of its digits must be equal. In our example, 1124 is indeed a spy number because both the sum and the product of its digits are 8.

Examples: 22, 123, 132, 1124.

Neon number

Neon Number is a special integer in the mathematics or programming world. This number has unique characteristics, as if you square the integer and then sum the digits of that square number it will result in the same integer. These types of numbers are rare and their unique property made it interesting to learn and study.

Example:

  • 9: 81 is the square of 9, and 9 is the total of its digits (8 + 1).
  • 0: The square of 0 is 0, and the sum of its digits is also 0.
  • 1: The square of 1 is 1, and the sum of its digits is also 1.
NOTE: There are only 3 neon numbers (0, 1, 9) in the first 1 lakh numbers tested.


Buzz number

Buzz number in Java is a number that is either divisible by 7 or ends with the digit 7.

Examples: 42, 107, 147, 207, 57.

Armstrong number

An Armstrong number (or narcissistic number) is an integer where the sum of its own digits, each raised to the power of the number of digits, equals the original number. 

Examples: 153,  370, 371, 407, 1634, 8208, 9474, 54748, 92727. 

Java program to access each letter of a string.

 //File name: StringLetters.java

//How to access each letter in a string.

import java.util.Scanner;

class StringLetters

{


public static void main(String[] args)

{

String name = "Ashutosh";

//First method. Using 'charAt()' and  'length()' methods of the String class.

for(int i =0; i < name.length(); i++)

{

System.out.println(name.charAt(i));

}

//Second Method.

//Print each letter using 'toCharArray()' method, that converts a string 

//to a char array and the 'length' property of an array.

//String[] nameStr = name.toCharArray(); Error: char[] cannot be converted to String[].

//Use character array instead.

char[] nameCharArray = name.toCharArray();

for(int i =0; i<nameCharArray.length; i++)

{

System.out.println(nameCharArray[i]);

}

}


}

Java menu-driven program to check if given number is a palindrome.

//File name: Palindrome.java


import java.util.Scanner;

class Palindrome{




static void palindrome ()

{

int originalNum;

int copyOforiginalNum=0;

int reverse_Num=0;

int digit=0;


System.out.println("Enter a number");

Scanner sc = new Scanner(System.in);

originalNum = sc.nextInt();

copyOforiginalNum = originalNum;


while(copyOforiginalNum>0)

{

digit = copyOforiginalNum%10;

reverse_Num = (reverse_Num*10) + digit;

copyOforiginalNum = copyOforiginalNum/10;

    

       }

if(originalNum == reverse_Num)

{

System.out.println("Palindrome");

}

else

{

System.out.println("Not a palindrome");

}



        }


public static void main(String[] args)

{


int choice = 1;

while(choice!=0)

{



palindrome();

System.out.println("Type 1 to continue else type 0 to exit.");

Scanner sc = new Scanner(System.in);

choice = sc.nextInt();

        }

  }

}

Area of trapezium formula derivation