A gas blocking device comprising: a flow rate measurement portion that measures a flow rate of gas passing through a gas passage; a code extraction portion that extracts a code corresponding to a difference between a flow rate newly measured by the flow rate measurement portion and a previously-measured flow rate and that outputs as a first code pattern a plurality of codes extracted during a predetermined period of time; an initial code learning portion; and a code maintaining portion (208; 408) that maintains gas appliance code patterns; characterized in that the initial code learning portion: receives a plurality of code patterns from the code extraction portion; counts the number of times the same code pattern of the plurality of code patterns appears within a predetermined period of time; extracts the code patterns having emerged a predetermined number of times or more within a predetermined period of time; takes, as a reference, the first code pattern of the plurality of code patterns having emerged a predetermined number of times or more within a predetermined period of time: calculates the difference between each code pattern of the plurality of first code patterns and the reference code pattern; gathers code patterns similar to said reference code pattern by taking code patterns that have a predetermined difference or less with respect to the reference code pattern; determines an average of the similar code patterns on a per-code basis and calculates a gas appliance code pattern by rounding off the average to the nearest whole number, or determines a weighted mean of the similar code patterns by a number of times respective code patterns emerged to calculate a gas appliance code pattern, or adopts a code pattern having a smallest difference number with respect to the similar code patterns as a gas appliance code pattern. a flow rate measurement portion that measures a flow rate of gas passing through a gas passage; a code extraction portion that extracts a code corresponding to a difference between a flow rate newly measured by the flow rate measurement portion and a previously-measured flow rate and that outputs as a first code pattern a plurality of codes extracted during a predetermined period of time; an initial code learning portion; and a code maintaining portion (208; 408) that maintains gas appliance code patterns; characterized in that the initial code learning portion: receives a plurality of code patterns from the code extraction portion; counts the number of times the same code pattern of the plurality of code patterns appears within a predetermined period of time; extracts the code patterns having emerged a predetermined number of times or more within a predetermined period of time; takes, as a reference, the first code pattern of the plurality of code patterns having emerged a predetermined number of times or more within a predetermined period of time: calculates the difference between each code pattern of the plurality of first code patterns and the reference code pattern; gathers code patterns similar to said reference code pattern by taking code patterns that have a predetermined difference or less with respect to the reference code pattern; determines an average of the similar code patterns on a per-code basis and calculates a gas appliance code pattern by rounding off the average to the nearest whole number, or determines a weighted mean of the similar code patterns by a number of times respective code patterns emerged to calculate a gas appliance code pattern, or adopts a code pattern having a smallest difference number with respect to the similar code patterns as a gas appliance code pattern. receives a plurality of code patterns from the code extraction portion; counts the number of times the same code pattern of the plurality of code patterns appears within a predetermined period of time; extracts the code patterns having emerged a predetermined number of times or more within a predetermined period of time; takes, as a reference, the first code pattern of the plurality of code patterns having emerged a predetermined number of times or more within a predetermined period of time: calculates the difference between each code pattern of the plurality of first code patterns and the reference code pattern; gathers code patterns similar to said reference code pattern by taking code patterns that have a predetermined difference or less with respect to the reference code pattern; determines an average of the similar code patterns on a per-code basis and calculates a gas appliance code pattern by rounding off the average to the nearest whole number, or determines a weighted mean of the similar code patterns by a number of times respective code patterns emerged to calculate a gas appliance code pattern, or adopts a code pattern having a smallest difference number with respect to the similar code patterns as a gas appliance code pattern.