login
a(n) = n^2 mod(10^m), where m is the number of digits in n (written in base 10).
3

%I #29 Jan 17 2019 23:15:01

%S 0,1,4,9,6,5,6,9,4,1,0,21,44,69,96,25,56,89,24,61,0,41,84,29,76,25,76,

%T 29,84,41,0,61,24,89,56,25,96,69,44,21,0,81,64,49,36,25,16,9,4,1,0,1,

%U 4,9,16,25,36,49,64,81,0,21,44,69,96,25,56,89,24,61,0,41,84,29

%N a(n) = n^2 mod(10^m), where m is the number of digits in n (written in base 10).

%C The set of the terms is the same as that of A238712.

%H Georg Fischer, <a href="/A316347/b316347.txt">Table of n, a(n) for n = 0..10000</a>, Jan 16 2019 (terms a(0..719585) initially submitted by Christopher D Chamness).

%e n = 13 has 2 digits in base 10, thus a(13) = 169 mod 100 = 69.

%o (Python)

%o i=1

%o while True:

%o m=i

%o j=i**2

%o l=0

%o while True:

%o m=m/10

%o l+=1

%o if m==0:

%o break

%o mod_num = 10**l

%o print j%mod_num

%o i+=1

%o (PARI) a(n) = n^2 % 10 ^ #digits(n) \\ _David A. Corneth_, Jun 30 2018

%o (Perl) my $mod = 10;

%o foreach my $i(0..10000) {

%o print "$i " . (($i * $i) % $mod) . "\n";

%o if (length($i + 1) > length($i)) { $mod *= 10; }

%o } # _Georg Fischer_, Jan 16 2019

%Y Cf. A238712.

%K nonn,base,easy

%O 0,3

%A _Christopher D Chamness_, Jun 29 2018