CHECKSUM

From Pickwiki
Revision as of 23:48, 26 February 2015 by Conversion script (talk) (link fix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Java implementation of the UniBasic CHECKSUM function:

static long checksum( String input )
{
      char[] chars = new char[ input.length() ];
      input.getChars(0, chars.length, chars, 0);
     
      long answer = 0L;
      for (int i = 0; i< chars.length ; i++) {
         answer += ((int)chars[i]) * (i+1);
      }
      
      return answer;
}