From 9bfff5cebb513d1ef3d063000eb668e4559fa240 Mon Sep 17 00:00:00 2001 From: Simon Proctor Date: Tue, 7 May 2019 12:54:34 +0100 Subject: Challenge 1. Niven numbers. --- challenge-007/simon-proctor/perl6/ch-1.p6 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 challenge-007/simon-proctor/perl6/ch-1.p6 diff --git a/challenge-007/simon-proctor/perl6/ch-1.p6 b/challenge-007/simon-proctor/perl6/ch-1.p6 new file mode 100755 index 0000000000..f2ff5cf134 --- /dev/null +++ b/challenge-007/simon-proctor/perl6/ch-1.p6 @@ -0,0 +1,13 @@ +#!/usr/bin/env perl6 + +use v6; + +multi sub is-niven( 0 ) { False } + +multi sub is-niven( Int $num where * > 0 ) { + $num %% [+] $num.comb; +} + +sub MAIN( UInt() $max=50 ) { + .say if is-niven($_) for 0..$max; +} -- cgit