{"id":17303,"date":"2021-08-26T10:42:44","date_gmt":"2021-08-26T05:12:44","guid":{"rendered":"https:\/\/python-programs.com\/?p=17303"},"modified":"2021-11-22T18:37:11","modified_gmt":"2021-11-22T13:07:11","slug":"python-program-to-check-strontio-number-or-not","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-strontio-number-or-not\/","title":{"rendered":"Python Program to Check Strontio Number or Not"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Find nth Prime Number<\/a> Strontio numbers are four-digit numbers that, when multiplied by two, produce the same digit in the hundreds and tens places. Keep in mind that the input number must be four digits.<\/p>\n example :<\/p>\n Let N= 1386<\/p>\n A number multiplied by 2= 1386*2=2772<\/p>\n 2772%1000 =772<\/p>\n 772\/10 = 77<\/p>\n 77\/10 = 7<\/p>\n 77%7= 7<\/p>\n if (77%7 == 77\/10 ), then it is strontio number.<\/p>\n Therefore 1386 is strontio number.<\/p>\n some of the examples of strontio numbers are :<\/p>\n 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 1001, 2002, 3003, and other numbers.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to check a strontio number or not.<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Explore more instances related to python concepts from\u00a0Python Programming Examples<\/a>\u00a0Guide and get promoted from beginner to professional programmer level in Python Programming Language.<\/p>\n In the previous article, we have discussed Python Program to Find nth Prime Number Strontio numbers: Strontio numbers are four-digit numbers that, when multiplied by two, produce the same digit in the hundreds and tens places. Keep in mind that the input number must be four digits. example : Let N= 1386 A number multiplied …<\/p>\n
\nStrontio numbers:<\/strong><\/p>\nGiven number = 1001<\/pre>\n
The given number 1001 is strontio number<\/pre>\n
Given number = 1234<\/pre>\n
The given number 1234 is not a strontio number<\/pre>\n
Program to Check Strontio Number or Not.<\/h2>\n
\n
Method #1: Using modulus Operator (Static Input)<\/h3>\n
\n
# Give the number as static input and store it in a variable.\r\nnum = 1001\r\n# Multiply the given number a store it in another variable.\r\nmul_numb = num*2\r\n# Calculate the value of the above-obtained number modulus 1000 to get a remainder\r\n# and store it in another variable say \"a\".\r\na = mul_numb % 1000\r\n# Divide the variable 'a' by 10 to remove the last digit and store it in\r\n# another variable say 'b'.\r\nb = a\/\/10\r\n# Again divide the variable 'b' by 10 to remove the last digit (quotient)and\r\n# store it in another variable say\u00a0 'c'.\r\nc = b\/\/10\r\n# Calculate the value of b%10 to get the remainder and store it in another variable\r\n# say\u00a0'd'.\r\nd = b % 10\r\n# Check if both the quotient and remainder are equal or not (c==d) using the if conditional statement.\r\nif(c == d):\r\n # If the statement is true, then print \"The given number is strontio number\".\r\n print(\"The given number\", num, \"is strontio number\")\r\nelse:\r\n # Else print \"Not Stronio Number\".\r\n print(\"The given number\", num, \"is not a strontio number\")\r\n<\/pre>\n
The given number 1001 is strontio number<\/pre>\n
Method #2: Using modulus Operator\u00a0 (User Input)<\/h3>\n
\n
# Give the number as user input using the int(input()) function and\r\n# store it in a variable.\r\nnum = int(input(\"Enter some random Number = \"))\r\n# Multiply the given number a store it in another variable.\r\nmul_numb = num*2\r\n# Calculate the value of the above-obtained number modulus 1000 to get a remainder\r\n# and store it in another variable say \"a\".\r\na = mul_numb % 1000\r\n# Divide the variable 'a' by 10 to remove the last digit and store it in\r\n# another variable say 'b'.\r\nb = a\/\/10\r\n# Again divide the variable 'b' by 10 to remove the last digit (quotient)and\r\n# store it in another variable say\u00a0 'c'.\r\nc = b\/\/10\r\n# Calculate the value of b%10 to get the remainder and store it in another variable\r\n# say\u00a0'd'.\r\nd = b % 10\r\n# Check if both the quotient and remainder are equal or not (c==d) using the if conditional statement.\r\nif(c == d):\r\n # If the statement is true, then print \"The given number is strontio number\".\r\n print(\"The given number\", num, \"is strontio number\")\r\nelse:\r\n # Else print \"Not Stronio Number\".\r\n print(\"The given number\", num, \"is not a strontio number\")\r\n<\/pre>\n
Enter some random Number = 5555\r\nThe given number 5555 is strontio number<\/pre>\n
\n