#!/usr/bin/env ruby # encoding: utf-8 # The initial hash value H(0) is the sequence of 8 32-bits words which # are obtained by taking the fractional parts of the square root of # the 8 first prime numbers FirstPrimes = [2, 3, 5, 7, 11, 13, 17, 19] if __FILE__ == $0 FirstPrimes.each_with_index do |prime,index| square_root = Math.sqrt(prime) current = square_root - square_root.to_i result = 0 32.times do current *= 2 result <<= 1 if current > 1 result |= 1 current -= 1 end end puts "H#{index + 1}(0) = #{result.to_s(16)}" end end