+ 1

How to print automorphic number between 1 to 1000.....plz make this in simple way

Automorphic number is a number whose ends in the same digits as the number itself.... for e.g. 25,625 Arun Tomar Helga Hans Larry HAWKEYE ‎ ‏‏‎Sreejith  Veerendra Kushwaha Fata1 Err0r Purab Gupta [A^dr3w] Dev

14th Aug 2018, 3:50 PM
Harsh Agrawal
Harsh Agrawal - avatar
6 odpowiedzi
+ 3
import java.util.Scanner; public class main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println("Type a number between 1 to 1000 :"); int number = sc.nextInt(); int length = Integer.toString(number).length(); int comparing = (int)Math.pow(number, 2); comparing = comparing % (int)Math.pow(10, length); if( number == comparing){ System.out.println(number + " is Automorphic number"); } else{ System.out.println(number + " is not an Autoporphic number"); } } } //sigh... one in here looks better than my code ( https://www.geeksforgeeks.org/automorphic-number/ )
14th Aug 2018, 9:09 PM
Jang Jaeung
Jang Jaeung - avatar
+ 5
Harsh Agrawal to print all automorphic numbers between 1 to 100, put Jang Jaeung's code in a for loop and remove scanner .... .... for (int number=1; number<=100; number++) { int length = Integer.toString(number).length(); ... ... if(number == comparing){ System.out.print(number) } ... ...
15th Aug 2018, 4:56 AM
‎ ‏‏‎Anonymous Guy
+ 1
Share your ideas, show us your attempts, we will help you. I would use "for loop" for this purpose and remainder operator (%).
14th Aug 2018, 5:42 PM
Steppenwolf
Steppenwolf - avatar
+ 1
Hi public class Automorphic { public static void main(String[] args) { System.out.println("All Automorphic Numbers between 1 and 1000.\n==========================================="); int div = 10; for(int num = 1; num <= 1000; num++) { if (div >= num) { if((num * num) % div == num) System.out.println( num ); } else if (div <= num) { div * = 10; if((num * num) % div == num) System.out.println( num ); } } } } https://code.sololearn.com/cMWOeOYm0mln/?ref=app hope this helps
15th Aug 2018, 9:17 AM
[A^dr3w]
[A^dr3w] - avatar
0
Can someone code in python plzz
9th Apr 2020, 4:36 PM
Pravallika Vanamala
Pravallika Vanamala - avatar
0
https://code.sololearn.com/cYS2O4BQRm2e/?ref=app print("All Automorphic Numbers between 1 and 1000.\n===========================================") div = 10 for num in range(1,1000): if (div >= num): if((num * num) % div == num): print( num ) elif (div <= num): div *= 10 if((num * num) % div == num): print( num )
9th Apr 2020, 5:38 PM
[A^dr3w]
[A^dr3w] - avatar