CHECKSUM

From Pickwiki
Revision as of 01:01, 9 November 2002 by Wendy (talk) (Java implementation of the UniBasic CHECKSUM function)
(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;
}