Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Digital-root/Huginn/digital-root.huginn
Normal file
16
Task/Digital-root/Huginn/digital-root.huginn
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
main( argv_ ) {
|
||||
if ( size( argv_ ) < 2 ) {
|
||||
throw Exception( "usage: digital-root {NUM}" );
|
||||
}
|
||||
n = argv_[1];
|
||||
if ( ( size( n ) == 0 ) || ( n.find_other_than( "0123456789" ) >= 0 ) ) {
|
||||
throw Exception( "{} is not a number".format( n ) );
|
||||
}
|
||||
shift = integer( '0' ) + 1;
|
||||
acc = 0;
|
||||
for ( d : n ) {
|
||||
acc = 1 + ( acc + integer( d ) - shift ) % 9;
|
||||
}
|
||||
print( "{}\n".format( acc ) );
|
||||
return ( 0 );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue