Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I also watched the video this morning, not realizing it came up because it was new.

When I saw that Matt was using Python to code it, of course I wanted to try it in Perl instead!

This was what I came up with:

#!/usr/bin/perl use strict; use warnings; use feature qw( say ); use Function::Parameters; $| = 1; # Try the record-holder try_num(277777788888899, 1); # Search for record holders at each # iterations my $num = my $max = my $maxn = my $print = 0; while (1) { ++$num; my ($per, $new) = (persist($num), 0); (0 == $num % 100_000) and $print = 1; ($per > $max) and ($maxn, $max, $print, $new) = ($num, $per, 1, 1) +; $print and print " CURR=$num, MAX=$max, MAXP=$maxn\e[K\r"; $new and say ""; $print = $new; } fun try_num($num, $dbg = 0) { my $per = persist($num, $dbg); printf "\e[102m Count[$num] = %s\e[m\n\n", persist($num, $dbg); } fun muldigs($num, $dbg = 0, $res = 1) { $dbg and say " Num: $num"; my @dbg = ( ); map { push @dbg, ($res *= $_) } split(//, $num); $dbg and say " -> " . join(",", @dbg); return $res; } fun persist($num, $dbg = 0) { my ($mul, $iter) = ($num, 0); while (1) { (length($mul) > 1) or return $iter; ($iter, $mul) = ($iter+1, muldigs($mul, $dbg)); $dbg and say "Iter: $iter [$mul]\n"; } }
say  substr+lc crypt(qw $i3 SI$),4,5

In reply to Re: Multiplication digit persistence by golux
in thread Multiplication digit persistence by tobyink

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found