Tech Jargon - Decoded
الذهاب إلى القناة على Telegram
Confused by tech terms? Don’t worry, we’ve got you 🤝 We make things simple, one concept at a time. Learn daily Easy & clear Turn Confusion into clarity. #tech #it #softwareengineer #cs #development
إظهار المزيد2 015
المشتركون
-124 ساعات
-57 أيام
-4030 أيام
أرشيف المشاركات
Check Perfect Number
public class PerfectNumber {
public static boolean isPerfectNumber(int num) {
if (num <= 1) return false;
int sum = 1;
for (int i = 2; i * i <= num; i++) {
if (num % i == 0) {
sum += i;
if (i * i != num) {
sum += num / i;
}
}
}
return sum == num;
}
public static void main(String[] args) {
System.out.println(isPerfectNumber(28));
System.out.println(isPerfectNumber(12));
}
}Check Armstrong Number
class Armstrong {
static boolean isArmstrong(int n) {
int temp = n, digits = 0, last = 0, sum = 0;
while (temp > 0) {
temp = temp / 10;
digits++;
}
temp = n;
while (temp > 0) {
last = temp % 10;
sum += (Math.pow(last, digits));
temp = temp / 10;
}
return (n == sum);
}
public static void main(String[] args) {
int num = 153;
if (isArmstrong(num))
System.out.println(num + " is an Armstrong number");
else
System.out.println(num + " is not an Armstrong number");
}
}Check Palindromic Prime
class PalindromicPrime {
public static boolean isPalindrome(int num) {
int originalNum = num;
int reversedNum = 0;
while (num > 0) {
int remainder = num % 10;
reversedNum = reversedNum * 10 + remainder;
num /= 10;
}
return originalNum == reversedNum;
}
public static boolean isPrime(int num) {
if (num <= 1) return false;
for (int i = 2; i <= Math.sqrt(num); i++) {
if (num % i == 0) return false;
}
return true;
}
public static boolean isPalindromicPrime(int num) {
return isPalindrome(num) && isPrime(num);
}
public static void main(String[] args) {
int number = 131;
if (isPalindromicPrime(number)) {
System.out.println(number + " is a palindromic prime.");
} else {
System.out.println(number + " is not a palindromic prime.");
}
}
}Generate First N Prime Numbers
public class PrimeGenerator {
public static int[] generatePrimes(int n) {
if (n <= 0) {
return new int[0];
}
int[] primes = new int[n];
int count = 0;
int number = 2;
while (count < n) {
if (isPrime(number)) {
primes[count++] = number;
}
number++;
}
return primes;
}
private static boolean isPrime(int number) {
if (number <= 1) {
return false;
}
for (int i = 2; i <= Math.sqrt(number); i++) {
if (number % i == 0) {
return false;
}
}
return true;
}
public static void main(String[] args) {
int n = 10;
int[] primes = generatePrimes(n);
for (int prime : primes) {
System.out.print(prime + " ");
}
System.out.println();
}
}Check Prime Number in Range
public class PrimeInRange {
public static void main(String[] args) {
int start = 10;
int end = 50;
for (int i = start; i <= end; i++) {
if (isPrime(i)) {
System.out.println(i + " is prime");
}
}
}
public static boolean isPrime(int num) {
if (num <= 1) return false;
for (int i = 2; i <= Math.sqrt(num); i++) {
if (num % i == 0) return false;
}
return true;
}
}Find nCr using BigInteger
import java.math.BigInteger;
public class NcrBigInteger {
public static BigInteger nCr(int n, int r) {
if (r < 0 || r > n) {
return BigInteger.ZERO;
}
if (r == 0 || r == n) {
return BigInteger.ONE;
}
if (r > n / 2) {
r = n - r;
}
BigInteger res = BigInteger.ONE;
for (int i = 0; i < r; ++i) {
res = res.multiply(BigInteger.valueOf(n - i));
res = res.divide(BigInteger.valueOf(i + 1));
}
return res;
}
public static void main(String[] args) {
int n = 30;
int r = 15;
System.out.println("nCr(" + n + ", " + r + ") = " + nCr(n, r));
}
}Binary to Hex Conversion
public class BinaryToHex {
public static String binaryToHex(String binary) {
if (binary == null || binary.isEmpty() || binary.length() % 4 != 0) {
return "Invalid Binary Input";
}
StringBuilder hex = new StringBuilder();
for (int i = 0; i < binary.length(); i += 4) {
String nibble = binary.substring(i, i + 4);
int decimal = Integer.parseInt(nibble, 2);
hex.append(Integer.toHexString(decimal));
}
return hex.toString().toUpperCase();
}
public static void main(String[] args) {
String binaryString = "1010111100001111";
String hexString = binaryToHex(binaryString);
System.out.println("Binary: " + binaryString);
System.out.println("Hex: " + hexString);
}
}Hex to Decimal Conversion
public class HexToDecimal {
public static int hexToDecimal(String hex) {
int decimal = 0;
for (int i = 0; i < hex.length(); i++) {
char hexChar = hex.charAt(i);
int digitValue = hexCharToDecimal(hexChar);
if (digitValue == -1) {
throw new IllegalArgumentException("Invalid hex character: " + hexChar);
}
decimal = decimal * 16 + digitValue;
}
return decimal;
}
public static int hexCharToDecimal(char hexChar) {
if (hexChar >= '0' && hexChar <= '9') {
return hexChar - '0';
} else if (hexChar >= 'A' && hexChar <= 'F') {
return hexChar - 'A' + 10;
} else if (hexChar >= 'a' && hexChar <= 'f') {
return hexChar - 'a' + 10;
} else {
return -1;
}
}
public static void main(String[] args) {
String hexValue = "1A";
int decimalValue = hexToDecimal(hexValue);
System.out.println("Hexadecimal " + hexValue + " = Decimal " + decimalValue);
}
}Octal to Decimal Conversion
public class OctalToDecimal {
public static int octalToDecimal(String octal) {
int decimal = 0;
int power = 0;
for (int i = octal.length() - 1; i >= 0; i--) {
int digit = octal.charAt(i) - '0';
decimal += digit * Math.pow(8, power);
power++;
}
return decimal;
}
public static void main(String[] args) {
String octalNumber = "17";
int decimalNumber = octalToDecimal(octalNumber);
System.out.println(octalNumber + " in octal is " + decimalNumber + " in decimal.");
}
}Binary to Decimal Conversion
public class BinaryToDecimal {
public static int binaryToDecimal(String binary) {
int decimal = 0;
int power = 0;
for (int i = binary.length() - 1; i >= 0; i--) {
int digit = binary.charAt(i) - '0';
if (digit < 0 || digit > 1) {
throw new IllegalArgumentException("Invalid binary string: " + binary);
}
decimal += digit * Math.pow(2, power);
power++;
}
return decimal;
}
public static void main(String[] args) {
String binaryString = "101101";
int decimalValue = binaryToDecimal(binaryString);
System.out.println("Binary " + binaryString + " = Decimal " + decimalValue);
}
}
متاح الآن! بحث تيليغرام 2025 — أهم رؤى العام 
